5.php页面提交form表单
<html>
<head></head>
<body>
<form action = "5_1.php" method = "post">
username:<input type = "text" name = "username"></br>
password:<input type = "text" name = "password"></br>
<input type = "submit" value = "提交">
<input type = "reset" value = "重置">
</form>
</body>
</html>
5_1.php页面接收form表单,并进行处理
//设置用户名和密码
$arr_user = array("user","pwd");
$arr_pwd = array("user"=>"1111","pwd"=>"2222");
//接收从表单提交过来的值,并进行判断:
$username = isset($_POST['username'])?$_POST['username']:"";
$pwd = isset($_POST['password'])?$_POST['password']:"";
//用户名和密码的验证:
if(in_array($username,$arr_user)){
if($pwd == $arr_pwd[$username]){
echo "登陆成功";
}else{
die("密码错误"); //die是停止程序运行
}
}else {
die("用户名错误");
}