PHP获取客户端数据

时间:2014-11-03

浏览器 GET/POST传值

GET
1.GET表单(method="GET")
2.url:http://localhost/ceshi.php?name=张三&age=18&add=beijign

POST
POST表单(method="POST")

PHP接收浏览器传值

$_GET数组

$_POST数组

实例:

biaodan.html
<form action="jieshou.php" method="GET">
<!--<form action="jieshou.php" method="POST">-->
	用户名:<input type="text" name="username"><br>
	密   码:<input type="password" name="password"><br>
	<input type="submit">
</form>

jieshou.php
<?php
header('Content-Type:text/html;charset=utf-8');

echo '<hr>GET传值:';
print_r($_GET);

echo '<hr>POST传值:';
print_r($_GET);

echo '<hr>用户名是:' . $_GET['username'] . ' 密码是:' . $_GET['password'];
//echo '<hr>用户名是:' . $_POST['username'] . ' 密码是:' . $_POST['password'];
?>