I am making a html form on a website and then that form should be forwarded to an email. I am having a hard time with this. Dead line is near and i do not know what to do. Below is the code:
PHP code:
<?
if ($_POST){
if (!isset($_POST["FirstName"])){
echo "First name field empty";
return false;
}else {
$FirstName=$_POST["FirstName"];
}
if(!isset($_POST["LastName"])){
echo "Last name field empty";
return false;
}else {
$LastName=$_POST["LastName"];
}
if(!isset($_POST["DayPhone"])){
echo "Day Phone field empty";
return false;
}else {
$DayPhone=$_POST["DayPhone"];
}
if(!isset($_POST["EveningPhone"])){
echo "Evening Phone field empty";
return false;
}else {
$EveningPhone=$_POST["EveningPhone"];
}
if(!isset($_POST["email"])){
echo "Email field empty";
return false;
}else {
$email=$_POST["email"];
}
if(!isset($_POST["PreferredLocation"])){
echo "Preferred Location field empty";
return false;
}else {
$PreferredLocation=$_POST["PreferredLocation"];
}
if(!isset($_POST["NumberOfBedrooms"])){
echo "Number of bedrooms field empty";
return false;
}else {
$NumberOfBedrooms=$_POST["NumberOfBedrooms"];
}
if(!isset($_POST["NumberOfBathRooms"])){
echo "Number of bathrooms field empty";
return false;
}else {
$NumberOfBathRooms=$_POST["NumberOfBathRooms"];
}
if (!isset($_POST["SpecialFeatures"])){
$SpecialFeatures="None";
}else{
$SpecialFeatures=$_POST["SpecialFeatures"];
}
if (!isset($_POST["additionalCriteria"])){
$additionalCriteria="None";
}else{
$additionalCriteria=$_POST["additionalCriteria"];
}
$ToEmail = 'some@something.com';
$EmailSubject = 'Buying a Home form';
$mailheader = "From: ".$email."\r\n";
$mailheader .= "Reply-To: ".$email."\r\n";
$mailheader .= "Content-type: text/html; charset=iso-8859-1\r\n";
$MESSAGE_BODY = "Name: ".$FirstName." ".$LastName."<br>";
$MESSAGE_BODY .= "Daytime Phone: ".$DayPhone."<br>";
$MESSAGE_BODY .= "Eveningtime Phone: ".$EveningPhone."<br>";
$MESSAGE_BODY .= "Email: ".$email."<br>";
$MESSAGE_BODY .= "Preferred Location: ".$PreferredLocation."<br>";
$MESSAGE_BODY .= "Number Of Bedrooms: ".$NumberOfBedrooms."<br>";
$MESSAGE_BODY .= "Number Of Bathrooms: ".$NumberOfBathRooms."<br>";
$MESSAGE_BODY .= "Special Features: ".$SpecialFeatures."<br>";
$MESSAGE_BODY .= "Additioanl Criteria: ".$additionalCriteria."<br>";
mail($ToEmail, $EmailSubject, $MESSAGE_BODY, $mailheader) or die ("Failure");
header("Location: ?sent=true");
}
?>
HTML code contains a simple form and a submit button. Please help my boss is on my bum regarding this. I am a coop student and this is my first coop job. PLEASE HELP! ASAP :sad:
I REALLY APPRECIATE THE REPLIES.