";
throw new Exception($error);
}
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 tell us your name\n
";
}
if (empty($_POST['Phone']))
{
$error .= "Please enter a phone number\n
";
}
if (empty($_POST['Email']))
{
$error .= "Please enter a valid email address\n
";
}
if (empty($_POST['Address']))
{
$error .= "Please enter your address\n
";
}
if ($_POST['Info consent'] != "on")
{
$error .= "You need to consent to us collecting the information or we can't process your enquiry\n
";
}
if (empty($_POST['Date of Birth']))
{
$error .= "Please enter your date of birth\n
";
}
if (empty($_POST['Emergency']))
{
$error .= "Please enter emergency contact details\n
";
}
if ($_POST['Terms'] != "on")
{
$error .= "You must read and agree our terms\n
";
}
if (!empty($error))
{
throw new Exception($error);
}
$message .= $eol;
$message .= "IP Address : ";
$message .= $_SERVER['REMOTE_ADDR'];
$message .= $eol;
foreach ($_POST as $key => $value)
{
if (!in_array(strtolower($key), $internalfields))
{
if (is_array($value))
{
$message .= ucwords(str_replace("_", " ", $key)) . " : " . implode(",", $value) . $eol;
}
else
{
$message .= ucwords(str_replace("_", " ", $key)) . " : " . $value . $eol;
}
}
}
$body = 'This is a multi-part message in MIME format.'.$eol.$eol;
$body .= '--'.$boundary.$eol;
$body .= 'Content-Type: text/plain; charset=UTF-8'.$eol;
$body .= 'Content-Transfer-Encoding: 8bit'.$eol;
$body .= $eol.stripslashes($message).$eol;
if (!empty($_FILES))
{
foreach ($_FILES as $key => $value)
{
if ($_FILES[$key]['error'] == 0)
{
$body .= '--'.$boundary.$eol;
$body .= 'Content-Type: '.$_FILES[$key]['type'].'; name='.$_FILES[$key]['name'].$eol;
$body .= 'Content-Transfer-Encoding: base64'.$eol;
$body .= 'Content-Disposition: attachment; filename='.$_FILES[$key]['name'].$eol;
$body .= $eol.chunk_split(base64_encode(file_get_contents($_FILES[$key]['tmp_name']))).$eol;
}
}
}
$body .= '--'.$boundary.'--'.$eol;
if ($mailto != '')
{
mail($mailto, $subject, $body, $header);
}
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;
}
?>