In the form, we have a method attribute, which enables the form to be post and get. in php, we should use the corresponding get and post to receive it, the following describes the method parameters.
1. I used it before. When submitting form post, the url of the action passes the get parameter, which can be obtained by the server:
| The Code is as follows: |
Copy code |
<? Php Print_r ($ _ GET ); Print_r ($ _ POST ); ?> <Form action = "get_post.php? Id = 100 "method =" post "> Name: <input type = "text" name = "name"/> <br> Age: <input type = "text" name = "age"/> <br> <Input type = "submit" value = "submit"/> </Form> |
2. If your form submission type is get, the parameters passed in the url cannot be obtained:
| The Code is as follows: |
Copy code |
<? Php /** * Test get and post submission. * @ Link (http://www.bKjia. c0m) */ Print_r ($ _ GET ); Print_r ($ _ POST ); ?> <Form action = "get_post.php? Id = 100 "method =" get "> Name: <input type = "text" name = "name"/> <br> Age: <input type = "text" name = "age"/> <br> <Input type = "submit" value = "submit"/> </Form> |