$name=$_POST["name"]
$pwd=$_POST["pwd"]
if($_POST["sun"]){
if(isset($name) || isset($pwd) )
exit()
}
if($name!="admin" || $pwd!="123456"){
$err="对不起用户名或者密码不正确";
exit()
}
if($name=="admin" &&$pwd=="123456"){
$err="登陆成功!"
}
}
?>
<html>
<title></title>
<head></head>
<body>
<form method="post" action="填写本页的网页名字例如(index.php)">
用户名:<input type="text" name="name" ><?php echo $err ?><br/>
密码:<input type="password" name="pwd"><br/>
<input type="submit" name="sub" value="登陆"/><input type="reset"/>
</form>
</body>
</html>
将下面代码保存为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/htmlcharset=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/htmlcharset=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 '用户名或密码错误'
}
?>
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)