- # uncomment the following lines to save the values recieved to the
- # database. You can use ~form_name~.sql to create the database table.
- #require_once('db_connect.php');
- #db_insert('~form_name~', '~db_fields~', ~php_fields~);
+ # to enable saving to a database, create a file called 'db_connect.php'
+ # see: code/wfpl/examples/db_connect.php
+ if(file_exists('db_connect.php')) {
+ require_once('db_connect.php');
+ if($edit_id) {<!--~image_db start~-->
+ # uploading nothing means leaving it as is.
+ if(!$~name~ && $delete_~name~ != 'Yes') {
+ $~name~ = db_get_value('~form_name~', '~name~', 'id = %"', $edit_id);
+ }
+ <!--~end~-->
+ db_update('~form_name~', '~db_fields~', ~php_fields~, 'id = %"', $edit_id);
+ tem_set('did', 'updated');
+ } else {
+ db_insert('~form_name~', '~db_fields~', ~php_fields~);
+ tem_set('did', 'saved');
+ }
+ }