將下面代碼保存為login.php 和 confirm.php,然后運(yùn)行l(wèi)ogin.php就可以
創(chuàng)新互聯(lián)公司成都網(wǎng)站建設(shè)按需網(wǎng)站策劃,是成都網(wǎng)站建設(shè)公司,為成都紗窗提供網(wǎng)站建設(shè)服務(wù),有成熟的網(wǎng)站定制合作流程,提供網(wǎng)站定制設(shè)計(jì)服務(wù):原型圖制作、網(wǎng)站創(chuàng)意設(shè)計(jì)、前端HTML5制作、后臺(tái)程序開(kāi)發(fā)等。成都網(wǎng)站設(shè)計(jì)熱線:18982081108
login.php
!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" ""
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
pinput 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 '用戶名或密碼錯(cuò)誤';
}
?
?php
$name=$_POST["name"];
$pwd=$_POST["pwd"];
if($_POST["sun"]){
if(isset($name) || isset($pwd) )
$err="對(duì)不起用戶名或者密碼不能為空";
exit();
}
if($name!="admin" || $pwd!="123456"){
$err="對(duì)不起用戶名或者密碼不正確";
exit();
}
if($name=="admin" $pwd=="123456"){
$err="登陸成功!"
}
}
?
html
title/title
head/head
body
form method="post" action="填寫本頁(yè)的網(wǎng)頁(yè)名字例如(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
有啊。直接將賬號(hào)密碼POST 到另一個(gè)PHP 接受。。
index.php
form name="form1" method="post" action="confirm.php"
p用戶名:input type="text" name="user"/p
p密碼:input type="password" name="pwd"/p
pinput type="submit" /p
/form
confirm.php
?php
$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 '用戶名或密碼錯(cuò)誤';
}
?