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.cs s" rel="stylesheet " type="text/css">
<script language="JavaS cript"></script>
</head>
<body leftmargin="0" topmargin="0">
<table width="750" border="0" align="center" cellpadding="2" cellspacing="0" bgcolor="#FFFFF F">
<tr>
<td height="20" align="right" valign="middle" class="condent" > <a href="index.htm " class="sitelink s">Home</a> | <span>Feed Back</span> &nbs p;</td>
</tr>
</table>
<form name="_ctl0" method="post" action="Reply.p hp" 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">&nb sp;*</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">&nb sp;*</font> </td>
<td>
<input name="txtEmailI d" id="txtEmailId " type="text" class="textbox" size="25" />
</td>
</tr>
<tr>
<td align="left" class="content" >Telephone <font color="red">&nb sp;*</font> </td>
<td>
<input name="txtTeleph one" id="txtTelephon e" type="text" class="textbox" size="25" />
</td>
</tr>
<tr>
<td align="left" class="content" >Comments <font color="red">&nb sp;*</font></td>
<td>
<textarea name="txtCommen ts" 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.n et.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,$heade rs,$feedback) ;
if($sent)
{
print "Your mail was sent successfully";
}
else
{print "We encountered an error sending your mail"; }
?>
</table>
</form>
</body>
</html>
<script language="JavaS cript" type="text/JavaScript">
function Add()
{
if (document.getEl ementById("txtN ame").value=="" )
{
alert("Please Enter the Name")
document.getEle mentById("txtNa me").focus();
return false;
}
if (document.getEl ementById("txtE mailId").value= ="")
{
alert("Please Enter the Email ID")
document.getEle mentById("txtEm ailId").focus() ;
return false;
}
if (document.getEl ementById("txtT elephone").valu e=="")
{
alert("Please Enter the Telephone")
document.getEle mentById("txtTe lephone").focus ();
return false;
}
if (document.getEl ementById("txtC omments").value =="")
{
alert("Please Enter the Comments")
document.getEle mentById("txtCo mments").focus( );
return false;
}
var PhoneNumber = /^[0-9\+\,\(\)\-\s]+/gi;
if(document.get ElementById("tx tTelephone").va lue!="")
{
if(!PhoneNumber .test(document. getElementById( "txtTelephone") .value))
{
alert("* Phone Number accepts numbers and Special Characters.");
document.getEle mentById("txtTe lephone").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.getEl ementById("txtE mailId").value) == false)
{
alert("* Please Enter Valid Email ID.");
document.getEle mentById("txtEm ailId").focus() ;
return false;
}
}
function Clear()
{
document.getEle mentById("txtNa me").value = "";
document.getEle mentById("txtEm ailId").value = "";
document.getEle mentById("txtTe lephone").value = "";
document.getEle mentById("txtAd dress").value = "";
document.getEle mentById("txtCi ty").value = "";
document.getEle mentById("txtCo untry").value = "";
document.getEle mentById("txtCo mments").value = "";
}
function Cancel()
{
window.location .href("index.ht m")
}
</script>
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.cs s" rel="stylesheet " type="text/css">
<script language="JavaS cript"></script>
</head>
<body leftmargin="0" topmargin="0">
<table width="750" border="0" align="center" cellpadding="2" cellspacing="0" bgcolor="#FFFFF F">
<tr>
<td height="20" align="right" valign="middle" class="condent" > <a href="index.htm " class="sitelink s">Home</a> | <span>Feed Back</span> &nbs p;</td>
</tr>
</table>
<form name="_ctl0" method="post" action="Reply.p hp" 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">&nb sp;*</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">&nb sp;*</font> </td>
<td>
<input name="txtEmailI d" id="txtEmailId " type="text" class="textbox" size="25" />
</td>
</tr>
<tr>
<td align="left" class="content" >Telephone <font color="red">&nb sp;*</font> </td>
<td>
<input name="txtTeleph one" id="txtTelephon e" type="text" class="textbox" size="25" />
</td>
</tr>
<tr>
<td align="left" class="content" >Comments <font color="red">&nb sp;*</font></td>
<td>
<textarea name="txtCommen ts" 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.n et.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,$heade rs,$feedback) ;
if($sent)
{
print "Your mail was sent successfully";
}
else
{print "We encountered an error sending your mail"; }
?>
</table>
</form>
</body>
</html>
<script language="JavaS cript" type="text/JavaScript">
function Add()
{
if (document.getEl ementById("txtN ame").value=="" )
{
alert("Please Enter the Name")
document.getEle mentById("txtNa me").focus();
return false;
}
if (document.getEl ementById("txtE mailId").value= ="")
{
alert("Please Enter the Email ID")
document.getEle mentById("txtEm ailId").focus() ;
return false;
}
if (document.getEl ementById("txtT elephone").valu e=="")
{
alert("Please Enter the Telephone")
document.getEle mentById("txtTe lephone").focus ();
return false;
}
if (document.getEl ementById("txtC omments").value =="")
{
alert("Please Enter the Comments")
document.getEle mentById("txtCo mments").focus( );
return false;
}
var PhoneNumber = /^[0-9\+\,\(\)\-\s]+/gi;
if(document.get ElementById("tx tTelephone").va lue!="")
{
if(!PhoneNumber .test(document. getElementById( "txtTelephone") .value))
{
alert("* Phone Number accepts numbers and Special Characters.");
document.getEle mentById("txtTe lephone").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.getEl ementById("txtE mailId").value) == false)
{
alert("* Please Enter Valid Email ID.");
document.getEle mentById("txtEm ailId").focus() ;
return false;
}
}
function Clear()
{
document.getEle mentById("txtNa me").value = "";
document.getEle mentById("txtEm ailId").value = "";
document.getEle mentById("txtTe lephone").value = "";
document.getEle mentById("txtAd dress").value = "";
document.getEle mentById("txtCi ty").value = "";
document.getEle mentById("txtCo untry").value = "";
document.getEle mentById("txtCo mments").value = "";
}
function Cancel()
{
window.location .href("index.ht m")
}
</script>
Comment