Submit the PHP form to yourself

Source: Internet
Author: User
Tags php form
Using PHP for Web development, forms can be seen everywhere. Using the Action and Method attributes, you can specify the URL of the Form content to be sent for processing and how to send the Form data to the server. In most cases, we specify another URL address to process the form content to the Action attribute, but in some cases, we need to submit the form data to ourselves. In this case, how should we specify the Action attribute value?
If (isset ($ _ POST ['action']) & $ _ POST ['action'] = 'submitted '){
Print'
';

Print_r ($ _ POST );
Print 'Please try again ';

Print'
';
} Else {
?>

}
?>
The above code implements the form submission to yourself (Note: Use $ _ HTTP_POST_VARS to replace the $ _ Post variable in the following code in PHP4.1.0 or earlier versions ). Here, the Server variable $ _ Server is used to obtain the URL address of the current page and assign it to the Action attribute of the form. A small trick is used here to determine whether a POST request or GET request is received by the server. Add a hidden variable to the form. when processing the request, we use the isset function to check whether this hidden variable is set. then, we can determine whether the request uses the POST or GET method.

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.