I have the following php script:
<?php
$name = $_REQUEST['name'];
$email = $_REQUEST['email'];
$subject = $_REQUEST['subject'];
$message = $_REQUEST['message'];
$submit = $_REQUEST['submit'];
$to = "torayevagajan@gmail.com";
if(isset($submit))
{
function isValidEmail($email)
{
return eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email);
}
if(!empty($name) && !empty($email) && !empty($message) && isValidEmail($email))
{
$text = "From: ".$email."<br>Name: ".$name."<br>".$message;
if(mail($to, $subject, $text) && !empty($submit)){
echo "<script type=\"text/javascript\">alert(\"Your message has been sent!\");</script>";
}
else{
echo "<script type=\"text/javascript\">alert(\"Error Occured!\");</script>";
}
}elseif(empty($name) || empty($email) || empty($message))
{
echo "<script type=\"text/javascript\">alert(\"Please fill in the all fields!\");</script>";
}else echo "<script type=\"text/javascript\">alert(\"Incorrect email format!\");</script>";
unset($submit);
}
?>
I have the following problem, after submitting details to contact php, whenever I want to refresh page, it tries again and again send mail, I mean it tries to run script, even I unset($submit); how can fix this?