首页 > 数据库 > MySQL > 正文

一个基于mysql的登陆验证程序(一)

2024-07-24 12:56:10
字体:
来源:转载
供稿:网友
<?
     /******************************************************
     file name: login.php3
     login check
     编码: php 4
     作者: kevin lee < [email protected] >

     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 "你已经成功登陆。。。"."<p>";
    echo "<center>"."窗口10秒钟后自动关闭"."</center>";
    echo "</body></html>";

  }
  else {
  echo "帐号或密码错误!!!";
  echo "<p>";
  echo "<center>";
  echo "<a href=/"#/" onclick=/"javascript:back()/">back</a>";
  echo "</center>" ;
  }
?>

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表