Hi,
I did a feedback form in PHP. When i click the submit button, the form is submitted and the mail has been sent successfully and all the fields had been clear. But then if i click the refresh button, automatically a mail is sent with the previous data. Can anyone help me out.
Here is the Code:
-----------------------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Falcon (c) Security Services - FeedBack</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<META HTTP-EQUIV="Refresh" CONTENT="90; URL=index.htm">
<link href="falcon.css" rel="stylesheet" type="text/css">
<script language="JavaScript"></script>
</head>
<body leftmargin="0" topmargin="0">
<table width="750" border="0" align="center" cellpadding="2" cellspacing="0" bgcolor="#FFFFFF">
<tr>
<td height="20" align="right" valign="middle" class="condent"> <a href="index.htm" class="sitelinks">Home</a> | <span>Feed Back</span> </td>
</tr>
</table>
<form name="_ctl0" method="post" action="Reply.php" id="_ctl0">
<table width="95%" border="0" align="center" cellpadding="10" cellspacing="0" id="tblFeedBack">
<tr>
<td align="left" class="content">Name <font color="red"> *</font> </td>
<td>
<input name="txtName" id="txtName" type="text" class="textbox" size="25" />
</td>
</tr>
<tr>
<td align="left" class="content">Email ID <font color="red"> *</font> </td>
<td>
<input name="txtEmailId" id="txtEmailId" type="text" class="textbox" size="25" />
</td>
</tr>
<tr>
<td align="left" class="content">Telephone <font color="red"> *</font> </td>
<td>
<input name="txtTelephone" id="txtTelephone" type="text" class="textbox" size="25" />
</td>
</tr>
<tr>
<td align="left" class="content">Comments <font color="red"> *</font></td>
<td>
<textarea name="txtComments" id="txtComments" class="textarea" rows="5" cols="25"></textarea></textarea>
</td>
</tr>
<tr><td> </td></tr>
<tr>
<td colspan = 2 align =center>
<input type="submit" name="btnSubmit" value="Submit" id="btnSubmit" class="content" OnClick="return Add();"/>
<input type="button" value="Clear" OnClick="Clear();" class = "content" name="clear" size="20">
<input type="button" value="Cancel" OnClick="Cancel();" class = "content" name="cancel" size="20">
</td>
</tr>
<?
$to = "pirai@falcon.net.in";
$subject = "Feedback";
$name = $_POST['txtName'] ;
$email = $_POST['txtEmailId'] ;
$telephone = $_POST['txtTelephone'] ;
$message = $_POST['txtComments'] ;
$headers = "From: $email";
$notes = stripcslashes($notes);
$feedback = "$name \n Email: $email \n Telephone: $telephone\n Comments: $message";
$sent = mail($to, $subject,$headers,$feedback) ;
if($sent)
{
print "Your mail was sent successfully";
}
else
{print "We encountered an error sending your mail"; }
?>
</table>
</form>
</body>
</html>
<script language="JavaScript" type="text/JavaScript">
function Add()
{
if (document.getElementById("txtName").value=="")
{
alert("Please Enter the Name")
document.getElementById("txtName").focus();
return false;
}
if (document.getElementById("txtEmailId").value=="")
{
alert("Please Enter the Email ID")
document.getElementById("txtEmailId").focus();
return false;
}
if (document.getElementById("txtTelephone").value=="" )
{
alert("Please Enter the Telephone")
document.getElementById("txtTelephone").focus();
return false;
}
if (document.getElementById("txtComments").value=="")
{
alert("Please Enter the Comments")
document.getElementById("txtComments").focus();
return false;
}
var PhoneNumber = /^[0-9\+\,\(\)\-\s]+/gi;
if(document.getElementById("txtTelephone").value!= "")
{
if(!PhoneNumber.test(document.getElementById("txtT elephone").value))
{
alert("* Phone Number accepts numbers and Special Characters.");
document.getElementById("txtTelephone").focus();
return false;
}
}
var EmailId = /^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]+/gi;
if(EmailId.test(document.getElementById("txtEmailI d").value) == false)
{
alert("* Please Enter Valid Email ID.");
document.getElementById("txtEmailId").focus();
return false;
}
}
function Clear()
{
document.getElementById("txtName").value = "";
document.getElementById("txtEmailId").value = "";
document.getElementById("txtTelephone").value = "";
document.getElementById("txtAddress").value = "";
document.getElementById("txtCity").value = "";
document.getElementById("txtCountry").value = "";
document.getElementById("txtComments").value = "";
}
function Cancel()
{
window.location.href("index.htm")
}
</script>