<?php
$errors = '';
date_default_timezone_set('Europe/London'); //set the time zone as server isnt in the uk or set to uk
$date = date('d/m/Y H:i:s'); //date variable
$ipaddress = $_SERVER["REMOTE_ADDR"]; //get the users ip address into a vairialbe
$myemail = 'peter.brickles@gmail.com';//<-----Put Your email address here.
$title = $_POST['title'];
$loan_amount = $_POST['loan_amount'];
$loan_purpose = $_POST['purpose'];
$first_name = $_POST['first_name'];
$surname = $_POST['surname'];
$postcode = $_POST['postcode'];
$house_number = $_POST['house_number'];
$street = $_POST['street'];
$town = $_POST['town'];
$hometype = $_POST['hometype'];
$home_phone = $_POST['home_phone'];
$mobile = $_POST['mobile'];
$work_number = $_POST['work_number'];
$email_address = $_POST['email'];
if (!preg_match(
"/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/i",
$email_address))
{
$errors .= "\n Error: Invalid email address";
}
if( empty($errors))
{
$to = $myemail;
$email_subject = "Contact form submission: $name";
$email_body = "You have received a new loan application. ".
" Here are the details:\n\n IP Address: $ipaddress \n Time/Date:$date \n\n Loan Amount: £$loan_amount\n Loan Purpose: $loan_purpose\n \n Title: $title \n Name: $first_name \n Surname: $surname \n\n Postcode: $postcode \n House Nymber\Name: $house_number \n Street: $street \n Town/City $town \n Home Type: $hometype \n Home Phone $home_phone \n Mobile: $mobile \n Work Number: $work_number \n Email: $email_address ";
$headers = "From: $myemail\n";
$headers .= "Reply-To: $email_address";
mail($to,$email_subject,$email_body,$headers);
//redirect to the 'thank you' page
header('Location: contact-form-thank-you.html');
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Contact form handler</title>
</head>
<body>
<!-- This page is displayed only if there is some error -->
<?php
echo nl2br($errors);
?>
</body>
</html>
Bookmarks