将下面代码保存为login.php 和 confirm.php,然后运行login.php就可以
login.php
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "
http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title> New Document </title>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta name="Generator" content="EditPlus">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
</head>
<body>
<form name="form1" method="post" action="confirm.php">
<p>用户名:<input type="text" name="user"></p>
<p>密码:<input type="password" name="pwd"></p>
<p><input type="submit" name="b1"></p>
</form>
</body>
</html>
confirm.php
<?
echo '<meta http-equiv="content-type" content="text/html; charset=utf-8">';
$user = isset($_POST['user'])? $_POST['user'] : '';
$pwd = isset($_POST['pwd'])? $_POST['pwd'] : '';
if(empty($user) || empty($pwd)){
echo '用户名和密码不能为空';
exit();
}
if($user=='user' && $pwd=='pwd'){
echo '登陆成功';
}else{
echo '用户名或密码错误';
}
?>