X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=metaform%2Ftemplate.php;h=8cbc9e94e49c0003e11be30772a2ee06b83ab5c3;hb=fe7ab127fc133be74b2601cbaa3ae789d7e2a2d7;hp=a3266de54d1ef63e306e85d70645c7229e06ffc7;hpb=3698f739c8155069451c61085ab925250c592e42;p=wfpl.git diff --git a/metaform/template.php b/metaform/template.php index a3266de..8cbc9e9 100644 --- a/metaform/template.php +++ b/metaform/template.php @@ -1,7 +1,14 @@ wfpl.'); } require_once('code/wfpl/template.php'); require_once('code/wfpl/format.php'); +require_once('code/wfpl/email.php'); #require_once('code/wfpl/db.php'); # fixme function ~form_name~_get_fields() { @@ -16,15 +23,37 @@ function ~form_name~_get_fields() { if(isset($_REQUEST['~always_field~'])) { ~form_name~_get_fields(); - if("you're happy with the values") { + if("you're happy with the POSTed values") { #db_insert('~form_name~', '~db_fields~', $GLOBALS['~form_name~_fields']); # fixme - header('Content-type: text/plain'); - print "e-mailing this: \n\n"; - tem_output('~form_name~.email.txt'); + 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>"; + } + } else { + $from = $to; + } + $subject = '~form_name~ form submitted'; + $message = tem_run('~form_name~.email.txt'); + $cc = ''; + $bcc = ''; + email($from, $to, $subject, $message, $cc, $bcc); + } + tem_load('~form_name~.html'); + tem_sub('thankyou'); + tem_output(); exit(); } + # otherwise, we display the form again. ~form_name~_get_fields() has + # already put the posted values back into the template engine, so they will + # show up in the form fields. You should add some message asking people to + # fix their entry in whatever way you require. } -tem_output('~form_name~.html'); +tem_load('~form_name~.html'); +tem_sub('form'); +tem_output(); ?>