I attempted to code a contact form for a website and this is what I came up with. I believe it works fine sending an email to the website owner, but I’m not sure if the email sent to the person using the form is coded correctly.
The address for the form is [URL=”http://www.streetartimpressions.com/contact.html”]http://www.streetartimpressions.com/contact.html
[code=php]<?php
//This section checks to make sure all required information was filled out.
if(empty($_POST[‘name’]) || empty($_POST[’email’]) || empty($_POST[‘phone’]) || empty($_POST[‘address1’]) || empty($_POST[‘address2’]) || empty($_POST[‘address3’]) || empty($_POST[‘comment’])) {
echo(‘Please go <a href=”javascript:history.go(-1)”>back</a> and complete all requested information.’);
//If all information was filled out, the script continues here.
} else {
//This section composes the body of the email that will be sent.
$today = date (“l, F jS Y H:i:s”);
$emailBody .= “nDate: $today n”;
$emailBody .= “———— nn”;
$emailBody .= “Name: “.$_POST[‘name’].” n”;
$emailBody .= “Email Address: “.$_POST[’email’].” n”;
$emailBody .= “Phone Number: “.$_POST[‘phone’].” n”;
$emailBody .= “Best time to call: “.$_POST[‘time’].” n”;
$emailBody .= ” n”;
$emailBody .= “Address:n”;
$emailBody .= $_POST[‘address1’].”n”;
$emailBody .= $_POST[‘address2’].”n”;
$emailBody .= $_POST[‘address3’].”n”;
$emailBody .= ” n”;
$emailBody .= “Comments:n”;
$emailBody .= $_POST[‘comment’].”n”;
$emailBody .= ” n”;
//This part of the code mails the form to the Street Art Impressions.
mail(“[email protected]”,”Contact from StreetArtImpressions.com”,$emailBody);
//This part of the code mails the form to the person contacting Street Art Impressions.
mail($email,”Thank you for contacting us”, “Thank you for contacting Street Art Impressions. If a reply is necessary, we will contact you at “.$_POST[’email’].” as soon as possible. Here’s a copy of the information you sent us:nn” .$emailBody);
//This will be displayed for the user after clicking submit.
echo(‘Thank you for taking the time to contact us. Please <a href=”http://www.streetartimpressions.com”>click here</a> to return to the main site.’);
}
?>
Can someone please verify for me if the [COLOR=”Blue”]$email[COLOR=”Green”].[COLOR=”Blue”]$email[COLOR=”Blue”]$email[COLOR=”Green”].[COLOR=”Blue”]$_POST[COLOR=”Green”][[COLOR=”Red”]’email’[COLOR=”Green”]][COLOR=”Green”].
Thanks for the help in advance.