This article mainly introduces two methods and simple examples of php form submission, which are very practical and can be referenced by other users.
Process GET requests
The function is to enter the name and the page displays "Hello XXX"
Create HTML file hello.html:
Welcome
Create the php file hello. php:
<? Php/*** 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 it is not empty, echo 'hello '. $ _ GET ['name'];} else {echo 'Please input name ';}
The Get request explicitly places the form data in the URI and has restrictions on the length and data value encoding, such as http: // 127.0.0.1/hello. php? Name = Vito
Process POST requests
Implement a simple addition operation
Create HTML file add.html:
Add
Create the php file add. php:
<?php/** * 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 without the length limit.
Form action = "" means: form is the form, action is the redirection address, that is, where the form must be submitted
The above is all the content of this article. I hope you will like it.