Why is my form automatically sent once every time I refresh it or enter the website?
$ Name = isset ($ _ POST ['uname'])? $ _ POST ['uname']: "";
$ Phone = isset ($ _ POST ['phone'])? $ _ POST ['phone']: "";
$ Company = isset ($ _ POST ['Company'])? $ _ POST ['Company']: "";
$ Message = isset ($ _ POST ['message'])? $ _ POST ['message']: "";
$ Msg = "name:". $ name ."
"." Phone: ". $ phone ."
"." Company: ". $ company ."
"." Message: ". $ message;
$ To = "long.cheng@freshds.com ";
$ Subject = "Soriana Contact ";
$ From = $ name;
$ Headers = "From: {$ name }";
If (mail ($ to, $ subject, $ msg, $ headers )){
Echo "script" alert ('Thanks for your support ') script ";
} Else {
Echo "script" alert ('failed') script ";
Return false;
}
?>
Reply to discussion (solution)
This depends on your submission judgment method.
If (mail ($ to, $ subject, $ msg, $ headers )){
Echo "script" alert ('Thanks for your support ') script ";
} Else {
Echo "script" alert ('failed') script ";
Return false;
}
No matter whether you have any value or not, the prompt box will pop out, and you have not made any judgment before.
This depends on your submission judgment method.
If (mail ($ to, $ subject, $ msg, $ headers )){
Echo "script" alert ('Thanks for your support ') script ";
} Else {
Echo "script" alert ('failed') script ";
Return false;
}
No matter whether you have any value or not, the prompt box will pop out, and you have not made any judgment before.
Function formcheck (){
If (document.info. uname. value = ''| document.info. company. value ='' | document.info. phone. value = ''){
Alert ("The fields with * is required ");
Return false;
}
}
Yes
The fields with * is required
Is this pop-up?
The form is sent directly.
The form is sent directly.
In this case, you did not determine whether to write a task. of course, it was sent directly.
If ($ _ SERVER ['request _ method']! = "POST") return;
Your original php code
You have to make a judgment first, or else it will be repeated twice ..