«
用PHP制作登录页面程序

时间:2008-5-31    作者:Deri    分类: 分享


   <code><?php<br />//这个脚本是用来给用户输入口令,并判断口令是否正确的。<br />//如果正确则转到欢迎页面。<br />if ($login){<br />  include("../include/config.inc.php3");<br />  session_start();<br />  $right_enter='0';<br />  $query="select * from user_define where user_login='$user_login' and user_pass=password('$user_pass')";<br />  $result=@mysql_query($query,$dbconnect);<br />  if ($user_array=@mysql_fetch_array($result)){<br />    $user_id=$user_array[user_id];<br />    $user_name=$user_array[user_info];<br />    session_register("user_id");<br />    session_register("user_name");<br />    session_register("user_array");<br />    if(($user_array[ticket_day]) and ($user_array[ticket_num])){<br />      $right_enter='1';<br />    }<br />    else{<br />      $error_message="对不起,您没有订票的权限!";<br />    }<br />  }<br />  else{<br />    $error_message="错误!用户名错,或口令错。请重新输入。";<br />  }<br />  $log_time=date("Y-m-d H:i:s");<br />  $query="insert into log_record (log_time,user_login,remote_addr,right_enter,enter_function) values ('$log_time','$user_login','$REMOTE_ADDR','$right_enter','1')";<br />  @mysql_query($query,$dbconnect);<br />  if($right_enter){<br />    Header("Location: welcome_reserve.php3");<br />    exit;<br />  }<br />}<br />if($logout){<br />  session_start();<br />  session_unregister("user_id");<br />  session_unregister("user_name");<br />  session_unregister("user_array");<br />}<br />?><br /><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><br /><html><br /><head><br />  <title>用户登录</title><br /><meta http-equiv="Content-Type" content="text/html; charset=gb2312"><br /><link rel="stylesheet" type="text/css" href="../include/njz_common.css"><br /></head><body><br /><p> </p><br /><form name="form1" method="post" action="<?php echo $PHP_SELF; ?>" ><br /> <table width="289" border="1" cellspacing="0" cellpadding="1" bordercolor="#999999" align="center"><br />  <tr bgcolor="#999999"><br />   <td><br />    <div align="center"><font color="#FFFFFF" size="4">用户登录</font></div><br />   </td><br />  </tr><br />  <tr><br />   <td><br />    <table width="267" border="0" cellspacing="0" cellpadding="5" align="center"><br />     <tr><br />      <td width="94"><br />       <div align="right">用户:</div><br />      </td><br />      <td width="169"><br />       <input type="text" name="user_login" size="16" maxlength="16" value="<?php echo $user_login; ?>"><br />      </td><br />     </tr><br />     <tr><br />      <td width="94"><br />       <div align="right">口令:</div><br />      </td><br />      <td width="169"><br />       <input type="password" name="user_pass" size="16" maxlength="16"><br />      </td><br />     </tr><br />     <tr><br />      <td colspan="2"><br />       <div align="center"><br />        <input type="submit" name="login" value=" 登 录 "><br />        <input type="button" name="return_index" value="返回首页" onClick="form1.action='../include/goto_page.php3?dist_page=../main.php3';form1.submit();return;"><br />       </div><br />      </td><br />     </tr><br />    </table><br />   </td><br />  </tr><br /> </table><br /></form><br /><?php<br />if($error_message) echo "<center><font color='#ff0000'>$error_message</font></center>";<br />?><br /><SCRIPT language="JavaScript">document.form1.user_login.focus();<br /></SCRIPT><br /><p> </p><br /><?php include("../footer.php3"); ?><br /></body><br /></html></code></p>