Using PHP for Web development, the use of forms (form) is ubiquitous, and its properties action and method allow you to specify the URL to which the form's content is to be sent and how to send the form data to the server. In most cases we specify another URL address to handle the contents of the form to the Action property, but there are also some cases where the form data needs to be submitted to itself. How do we specify the Action property value at this time?
Php
if (isset($_post['action']) &&$_post['action'] == ' submitted ' ){
Print '
' ;
Print_r ($_post);
Print ' '. $_server ['php_self'] . ' ">pleasetryagain ' ;
Print '
' ;
} Else {
?>
< formaction = " " Method = " POST " >
Name : < InputType = " text " name = " Personal[name] " >< BR >
Email : < InputType = " text " name = " Personal[email] " >< BR >
Beer : < BR >
< Selectmultiplename = " beer[] " >
< optionvalue = " Warthog " > Warthog
< optionvalue = " Guinness " > Guinness
Select><BR>
<InputType="Hidden"name="Action"value="submitted">
<InputType="Submit"name="Submit"value="submitme!">
form>
Php
}
?>
The code above implements the submission of the form to itself ( Note: Use $_http_post_vars instead of the $_post variable in the code below in the PHP4.1.0 version ). The server variable $_server is used here to get the URL address of the current page and assign it to the form's Action property. Here is a small trick used by the server to determine whether the URL request is a POST request or a GET request. is to add a hidden variable to the form, and when processing the request we detect whether the hidden variable is set by the isset function, thus determining if the request uses a post or get method.
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
The above describes how PHP submits the form to itself, including aspects of the content, I hope the PHP tutorial interested in a friend helpful.