I am creating a website. I want to use a simple contact form in it.To mail to contact the owner of the site. I got my form and validations on my form using HTML, Java Script and PHP. My form gives the message that email is sent. But I could not get anything in my mail box of (yahoo or gmail) do I need to configure my mail box also for this and how to do that? I am working on localhost using Xampp. Thank you for your time and help.
My code is in two files as follows. form.php and contact.php
form.php
function Validator()
{
var x=document.forms["myForm"]["fname"].value;
if (x==null || x=="")
{
alert("First name must be filled out");
return false;
}
var y=document.forms["myForm"]["email"].value;
if (y==null || y=="")
{
alert("Email must be filled out");
return false;
}
var z=document.forms["myForm"]["email"].value;
var atpos=z.indexOf("@");
var dotpos=z.lastIndexOf(".");
if (atpos<1 || dotpos
{
alert("Not a valid e-mail address");
return false;
}
}
Your name:
Your email:
Your message:
and contact.php as
$to = "[email protected]";
$subject = "Contact Us";
$email = $_REQUEST['email'] ;
$message = $_REQUEST['message'] ;
$headers = "From: $email";
$sent = mail($to, $subject, $message, $headers) ;
if($sent)
{print "Your mail was sent successfully"; }
else
{print "We encountered an error sending your mail"; }
?>
Replies
Know the answer? Post it — somebody with the same question will find it here.