Talking about PHP submitting form form
This article mainly introduces the 2 kinds of methods and simple examples of submitting form form in PHP, which is very practical and can be referred to by small partners.
Handling GET Requests
The function implemented is to enter the name after the page displays "Hello XXX"
To create an HTML file hello.html:
?
1 2 3 4 5 6 7 8 9 10 11 12 13 |
Welcome |
Create PHP file hello.php:
?
1 2 3 4 5 6 7 8 9 10 11 12 13 |
/** * Created by Phpstorm. * User:administrator * DATE:2015/6/30 * time:15:03 */ Header ("content-type:text/html; Charset=utf-8 "); if (isset ($_get[' name ')) &&$_get[' name ']) {//If there is a value and is not empty Echo ' Hello '. $_get[' name ']; }else{ echo ' please input name '; } |
A GET request explicitly places the form's data in a URI and limits the length and data value encoding, such as: Http://127.0.0.1/hello.php?name=Vito
Processing Post Requests
Implementation of a simple addition operation function
To create an HTML file add.html:
?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
Add |
Create PHP file add.php:
?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
/** * Created by Phpstorm. * User:administrator * DATE:2015/6/30 * TIME:18:02 */ if ($_post[' num1 ']&&$_post[' num2 ')} { echo $_post[' num1 ']+$_post[' num2 ']; }else{ echo ' please input num '; } |
The POST request places the form data in the HTTP request body with no length limit
Form action= "" means: Form is the form, action is the turn address, that is, where the form form needs to be submitted
The above mentioned is the whole content of this article, I hope you can like.
http://www.bkjia.com/PHPjc/1025319.html www.bkjia.com true http://www.bkjia.com/PHPjc/1025319.html techarticle A brief talk on PHP submitting form form This article mainly introduces the 2 kinds of methods and simple examples of submitting form form in PHP, which is very practical and can be referred to by the small partners. Handling Get please ...