A brief discussion on PHP form submission
This article mainly introduces two methods and simple examples of PHP submission form. It is very practical and can be used by those who need it. Partners can refer to it.
Handling GET requests
The function implemented is to display “Hello XXX” on the page after entering the name
Create html file hello.html:
?
1
2
3
4
5
6
7
8
9
10
11
12
13
|
欢迎
|
1
2
3
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']){//如果有值且不为空
echo 'Hello '.$_GET['name'];
}else{
echo 'Please input name';
}
|
4
5
6
7
8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
相加
|
9
10
11
12
13
|
Welcome
|
Create PHP file hello.php:
?
1
2
3
4
5
6
7
8
9
10
11
12
13
|
|
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
Handling POST requests
Implement a simple addition function
Create html file add.html:
?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
Add
|
创建PHP文件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';
}
|
1
2
3
4
5
6
7
8
9
10
11
12
13
|
|
Post请求把表单数据放在http请求体中,并且没有长度限制
form action=""意思是:form是表单,action是转向地址,即form表单需要提交到哪里
以上所述就是本文的全部内容了,希望大家能够喜欢。
http://www.bkjia.com/PHPjc/1025319.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/1025319.htmlTechArticle浅谈php提交form表单 这篇文章主要介绍了浅谈php提交form表单的2种方法和简单的示例,十分的实用,有需要的小伙伴可以参考下。 处理GET请...
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn