PHP中简单的form验证

在html文档中,简单的勾画出两个简单的input,注意,必须添加form标签,并添加要跳转的页面.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>登录界面</title>
</head>
<body>
<form action="denglu.php" method="GET">
<input type="text" name="userName">账户名称
<br>
<input type="password" name="passWord">密码
<br>
<input type="submit">
</form>
</body>
</html>

在php文档中进行验证,如下:
<?hp
@$userName=$_GET["userName"];
@$passWord=$_GET["passWord"];
if($userName=="zhangsan" and $passWord=="123456"){

echo "<script>";
echo "window.location.href='success.php?userName={$userName}'";
echo "</script>";

}else{
echo "<script>";
echo "window.location.href='fail.php?userName={$userName}'";
echo "</script>";
}
?>
原文地址:https://www.cnblogs.com/wybv587/p/6554959.html