"; } else { $from = $GLOBALS['contact_from']; } $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>"; } } if ($GLOBALS['contact_subject'] === '') { $subject = "Your message via $host/contact"; } else { $subject = $GLOBALS['contact_subject']; } $email_template = new tem(); $email_template->load('contact.email.txt'); $email_template->sets($data); $email_template->set('$host', $host); $message = $email_template->run(); $cc = $GLOBALS['contact_cc']; $bcc = ''; if (email($from, $to, $subject, $message, $reply_to, $cc, $bcc)) { message('Due to an internal error, your message could not be sent. Please try again later.'); $error = true; } else { message('Message sent'); } } if ($error !== true) { # FIXME create this page or change this to go elsewhere return './contact_thanks'; } } # otherwise, we display the form again. We've got the form field # values in $data and will put those back in the filds below. You # should add some message asking people to fix their entry in # whatever way you require. } else { # form not submitted, you can set default values like so: #$data = array('name' => 'Yes'); $data = array(); } tem_set('form', $data); }