明輝手游網(wǎng)中心:是一個免費提供流行視頻軟件教程、在線學(xué)習(xí)分享的學(xué)習(xí)平臺!

一個基于mysql的登陸驗證程序(一)

[摘要]<? /****************************************************** file name: login.php3 Login Check 編碼:...
<?
 /******************************************************
 file name: login.php3
 Login Check
 編碼: PHP 4
 作者: Kevin Lee < webwing@21cn.com >

 Database: MySQL。
 Host: localhost Database : mydb
 Table structure for table 'user'
--------------------------------------------------------
CREATE TABLE user (
 id smallint(6) NOT NULL auto_increment,
 user varchar(12) NOT NULL,
 passwd varchar(12) NOT NULL,
 name varchar(20),
 email varchar(30),
 level char(1),
 status char(1),
 UNIQUE id (id)
);
--------------------------------------------------------


*******************************************************/
?>
<script language="javascript">
function back(){
 history.back();
}
function winclose(){
 setTimeout("self.close()",10000);
}
</script>
<?
$db_id = mysql_pconnect("localhost", "root", "");
$sql="select id, user, passwd from user where user='".$name."' and passwd='".$pwd."'";
$result = mysql_db_query("mydb",$sql);
$row = mysql_fetch_array($result);
$id = $row[id] ;

if ($id!="") {
session_start();
session_register("yn");
$yn="yes";
echo "<html><body onload=\"javascript:winclose()\">";
echo "你已經(jīng)成功登陸。。。"."<p>";
echo "<center>"."窗口10秒鐘后自動關(guān)閉"."</center>";
echo "</body></html>";

}
else {
echo "帳號或密碼錯誤。!";
echo "<P>";
echo "<center>";
echo "<a href=\"#\" onclick=\"javascript:back()\">back</a>";
echo "</center>" ;
}
?>