|
html的参数如何通过超全局数组传递到php?
- html文件下的代码:
<html>
<head>
<meta charset = "utf-8" />
<title>超全局数组</title>
<boad>
<form action = "login.php" method="get">
<!--method用来设置html到PHP的传递类型,
一般默认为get类型,通过url进行参数传递
而post则不通过url传递参数-->
用户名:<input type = "xx" name = "username" />
<br />
密码:<input type = "123456" name = "password" />
<br />
<input type="submit" value="登录" />
</form>
</boad>
</head>
</html>
- login.php文件下的代码
<?php
$username = $_GET['username'];
$password = $_GET['password'];
$user = 'xx';
$pass = '123456';
if ($username == $user && $password == $pass)
{
echo '登录成功';
}
else
{
echo '登录失败';
}
- server.php文件下的代码:
<?php
var_dump($_SERVER);
|