Code: Select all
<?php
// get posted data into local variables
$EmailTo='admin@127.0.0.1';
$EmailFrom=Trim(strip_tags(stripslashes($_POST['from'])));
$Subject='Appointment Request';
$first=Trim(strip_tags(stripslashes($_POST['first'])));
$last=Trim(strip_tags(stripslashes($_POST['last'])));
$area=Trim(strip_tags(stripslashes($_POST['area'])));
$phone=Trim(strip_tags(stripslashes($_POST['phone'])));
$callwhen=Trim(strip_tags(stripslashes($_POST['callwhen'])));
$apptwhen=Trim(strip_tags(stripslashes($_POST['apptwhen'])));
$whatserv=Trim(strip_tags(stripslashes($_POST['whatserv'])));
$special=Trim(strip_tags(stripslashes($_POST['special'])));
// validate - this is where I'm having a problem
$validationOK == true;
$hasatmark = (strstr($EmailFrom, \"@"));
if ($hasatmark == false)
$validationOK == false;
else if (strlen($EmailFrom) <
$validationOK == false;
else if (strlen($first) < 2)
$validationOK == false;
else if (strlen($last) < 2)
$validationOK == false;
else if (strlen($area) > 3)
$validationOK == false;
else if (strlen($phone) < 10)
$validationOK == false;
if ($validationOK == true) {
print "<meta http-equiv=\"refresh\" content=\"0;URL=error.html\">";
exit;
}
// this will prepare email body text
$Body = "\n"
."\n"
."First Name: "
.$first
."\n"
."\n"
."Last Name: "
.$last
."\n"
."\n"
."Area Code: "
.$area
."\n"
."\n"
."Phone Number: "
.$phone
."\n"
."\n"
."Best Time To Call: "
.$callwhen
."\n"
."\n"
."Would Like An Appointment On: "
.$apptwhen
."\n"
."\n"
."Would Like These Services: "
.$whatserv
."\n"
."\n"
."Special Requests Are: "
.$special
."\n";
// send email
$success = mail($EmailTo, $Subject, $Body, $EmailFrom);
// redirect to success or failure page
if ($success){
print "<meta http-equiv=\"refresh\" content=\"0;URL=ok.html\">";
}
else{
print "<meta http-equiv=\"refresh\" content=\"0;URL=error.html\">";
}
?>