- if("you're happy with the POSTed values") {
- # 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') || file_exists('code/db_connect.php')) {
- if(file_exists('db_connect.php') {
- require_once('db_connect.php');
- } else {
- require_once('code/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~', 'where id=%i', $edit_id);
- }
- <!--~end~-->
- db_update('~form_name~', '~db_fields~', ~php_fields~, 'where id=%i', $edit_id);
- message('Entry updated.');
- } else {
- db_insert('~form_name~', '~db_fields~', ~php_fields~);
- message('Entry saved.');
- }
- }
- if($GLOBALS['~form_name~_form_recipient'] != "fixme@example.com") {
- $to = $GLOBALS['~form_name~_form_recipient'];
- if(isset($_REQUEST['email']) and valid_email($_REQUEST['email'])) {
- $from = $_REQUEST['email'];
- if($_REQUEST['name'] and ereg('^[a-zA-Z0-9_\' -]*$', $_REQUEST['name']) !== false) {
- $from = "$_REQUEST[name] <$from>";
+function ~file_name~_main_form($id = false) {~pulldowns {~
+ pulldown('~name~', ~pulldown_options~);~}~~has_pulldowns {~
+~}~~opt_db {~
+ if ($id) {
+ tem_set('id', $id);
+ }
+~}~
+ if (isset($_POST['~always_field~'])) {
+ $data = ~file_name~_get_fields();
+
+ if ("you're happy with the POSTed values") {~opt_db {~
+ if ($id) {
+ db_update_assoc('~table_name~', $data, 'where id=%i', $id);
+ message('~singular cap~ updated.');
+ } else {
+ db_insert_assoc('~table_name~', $data);
+ message('~singular cap~ saved.');
+ }~}~~opt_email {~
+ if ($GLOBALS['~file_name~_form_recipient'] != 'fixme@example.com') {
+ $to = $GLOBALS['~file_name~_form_recipient'];
+ $from = 'noreply@~this_domain~';
+ $reply_to = $to;
+ if (isset($data['email']) and valid_email($data['email'])) {
+ $reply_to = $data['email'];
+ if ($data['name'] and ereg('^[a-zA-Z0-9_\' -]*$', $data['name']) !== false) {
+ $reply_to = "$data[name] <$reply_to>";