Why is my form automatically sent once every time I refresh it or enter the website?

Source: Internet
Author: User
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 ..

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.