test1.php
<html>
<head>
</head>
<body>
<form method = 'post' action='test2.php' >
<p>用户名:<input type='text' name='username' id='name'></p>
<p>密 码:<input type='password' name='password'></p>
<p><input type='submit' value='登录'></p>
</form>
<script>
var names = document.getElementById('name');
names.value = '';
</script>
</body>
</html>
test2
<?php
$name = $_POST['username'];
$pwd = $_POST['password'];
if($name == '张三' && $pwd == '123456')
{
echo "<script>
alert('登录成功');
window.location.href='test3.php';
</script>";
}else{
echo "<script>
alert('用户名或者密码出现错误!请您重新输入');
history.back();
</script>";
}
?>
test3
<?php
echo '张三!欢迎您!';