The entered code was wrong.
';
echo 'Go Back';
exit;
}
}
?>
$value)
{
if (is_array($value))
{
$value = implode(",", $value);
}
$name = "$" . $key;
$code = str_replace($name, $value, $code);
}
$code = str_replace('$ipaddress', $_SERVER['REMOTE_ADDR'], $code);
return $code;
}
if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['formid']) && $_POST['formid'] == 'contact')
{
$mailto = 'leveriswalton@gmail.com';
$mailfrom = 'leswaltonrea@host17.registrar-servers.com';
$subject = 'Property Enquiry - Sales Contact Form';
$message = 'Sales Property Enquiry - Contact Form Submitted!
Name: $name
Email: $email
Phone: $phone
Interested In (Property): $property
Message:
$message
';
$success_url = './Contact_SuccessPage.html';
$error_url = './Contact_FailedPage.html';
$eol = "\n";
$error = '';
$mail = new PHPMailer(true);
try
{
$subject = ReplaceVariables($subject);
$mail->Subject = stripslashes($subject);
$mail->From = $mailfrom;
$mail->FromName = $mailfrom;
$mailto_array = explode(",", $mailto);
for ($i = 0; $i < count($mailto_array); $i++)
{
if(trim($mailto_array[$i]) != "")
{
$mail->AddAddress($mailto_array[$i], "");
}
}
if (!ValidateEmail($mailfrom))
{
$error .= "The specified email address (" . $mailfrom . ") is invalid!\n
";
throw new Exception($error);
}
$mail->AddReplyTo($mailfrom);
foreach ($_POST as $key => $value)
{
if (preg_match('/www\.|http:|https:/i', $value))
{
$error .= "URLs are not allowed!\n
";
throw new Exception($error);
break;
}
}
if (empty($_POST['name']))
{
$error .= "Please enter a value for the \"name\" field.\n
";
}
if (empty($_POST['email']))
{
$error .= "Please enter a value for the \"email\" field.\n
";
}
if (empty($_POST['phone']))
{
$error .= "Please enter a value for the \"phone\" field.\n
";
}
if (empty($_POST['property']))
{
$error .= "Please enter a value for the \"property\" field.\n
";
}
if (!empty($error))
{
throw new Exception($error);
}
$mail->CharSet = 'ISO-8859-1';
if (!empty($_FILES))
{
foreach ($_FILES as $key => $value)
{
if ($_FILES[$key]['error'] == 0)
{
$mail->AddAttachment($_FILES[$key]['tmp_name'], $_FILES[$key]['name']);
}
}
}
$message = ReplaceVariables($message);
$message = stripslashes($message);
$mail->MsgHTML($message);
$mail->IsHTML(true);
$mail->Send();
header('Location: '.$success_url);
}
catch (Exception $e)
{
$errorcode = file_get_contents($error_url);
$replace = "##error##";
$errorcode = str_replace($replace, $e->getMessage(), $errorcode);
echo $errorcode;
}
exit;
}
?>