Thank you to John-Marc, Matt, and Dmitri!
Just wanted to post the working form processor script in case someone else needs one....
PHP Code:
<?php
/**
* Form Processing Script
* Version 0.1a
* @DATE November 29, 2006
* @author Genesis Font
* @copyright 2006 prolinuxwebhosting.com
* Form must have the following hidden fields: recipient (should be the email address that will receive the emailed message) and redirect (full url including http:// to the thankyou page)
*/
$datetime = date("l dS of F Y H:i:s");
$message = "On $datetime\n";
$message .= "<br />Here are the details of the form submission:\n";
while (list($key, $val) = each($_POST)) {
if ($key == 'redirect') {
$redirect = $val;
}
if ($key == 'recipient') {
$to = $val;
}
if (($key != 'redirect') and ($key != 'recipient')) {
$val = trim($val);
$message .= "<br />$key: $val\n";
}
}
// echo "$key: $val<br />";//debugging info
$lcval = strtolower($val);
$pos = strpos($lcval,"http://");
//Genesis' code//
$ServerName = $_SERVER["HTTP_HOST"];
$message .= "<br /> Site: $ServerName \n";
$visitorip = $_SERVER['REMOTE_ADDR'] ;
$message .= "<br /> IP: $visitorip \n";
//validation for fields included in form
//Visitor Name
if (strlen($_POST['full_name']) <1)
{
header("Location: error.php");
exit;
}
if (strlen($_POST['full_name']) >75)
{
header("Location: error.php");
exit;
}
//Visitor E-Mail
if (! ereg('[A-Za-z0-9_-]+\@[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+', $_POST['vis_email']))
{
header("Location: error.php");
exit;
}
if (strlen($_POST['vis_email']) == 0 )
{
header("Location: error.php");
exit;
}
//Not allowing <tags>
if ( ereg('[<>]', $_POST['comment']))
{
header("Location: error2.php");
exit;
}
//end validation
//Format Email
$email = $to;
$vis_email = $_POST['vis_email'] ;
$subject = "Form Submission from Yaolag Site";
$headers = "From: $vis_email\r\n";
$headers .= "Content-type: text/html\r\n";
//Send Email
mail($to,$subject,$message,$headers);
//redirect
header("Location: $redirect");
?>
Form Information required:
HTML Code:
<form id="form1" name="form1" method="post" action="formprocessor1.php">
<INPUT TYPE="hidden" NAME="redirect" VALUE="http://www.yoursite.com/thankyou.php">
<INPUT TYPE="hidden" NAME="recipient" VALUE="email address of recipient">