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.