Application of Session in PHP4 (1)--login page (LOGIN.PHP3)

Source: Internet
Author: User
Tags include log query
session| page <?php
This script is used to enter the password for the user and to determine if the password is correct.
If correct, go to the Welcome page.
if ($login) {
Include (".. /include/config.inc.php3 ");
Session_Start ();
$right _enter= ' 0 ';
$query = "SELECT * from User_define where user_login= ' $user _login ' and User_pass=password (' $user _pass ')";
$result = @mysql_query ($query, $dbconnect);
if ($user _array= @mysql_fetch_array ($result)) {
$user _id= $user _array[user_id];
$user _name= $user _array[user_info];
Session_register ("user_id");
Session_register ("user_name");
Session_register ("User_array");
if (($user _array[ticket_day]) and ($user _array[ticket_num])) {
$right _enter= ' 1 ';
}
else{
$error _message= "Sorry, you do not have the right to book tickets!" ";
}
}
else{
$error _message= "Wrong! User name is wrong, or password is wrong. Please re-enter it. ";
}
$log _time=date ("y-m-d h:i:s");
$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 ');
@mysql_query ($query, $dbconnect);
if ($right _enter) {
Header ("Location:welcome_reserve.php3");
Exit
}
}
if ($logout) {
Session_Start ();
Session_unregister ("user_id");
Session_unregister ("user_name");
Session_unregister ("User_array");
}
?>
<! DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 transitional//en" >

<title> User Login </title>
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 ">
<link rel= "stylesheet" type= text/css "href=". /include/njz_common.css ">
<p> </p>

<form name= "Form1" method= "Post" action= "<?php echo $PHP _self;?>" >
<table width= "289" border= "1" cellspacing= "0" cellpadding= "1" bordercolor= "#999999" align= "Center" >
<tr bgcolor= "#999999" >
<td>
<div align= "center" ><font color= "#FFFFFF" size= "4" > User login </font></div>
</td>
</tr>
<tr>
<td>
<table width= "267" border= "0" cellspacing= "0" cellpadding= "5" align= "Center" >
<tr>
&LT;TD width= ">"
<div align= "Right" > User:</div>
</td>
&LT;TD width= "169" >
<input type= "text" name= "User_login" size= "maxlength=" "value=" <?php echo $user _login;?> ">
</td>
</tr>
<tr>
&LT;TD width= ">"
<div align= "Right" > Password:</div>
</td>
&LT;TD width= "169" >
<input type= "Password" name= "User_pass" size= "maxlength=" >
</td>
</tr>
<tr>
&LT;TD colspan= "2" >
<div align= "center" >
<input type= "Submit" name= "Login" value= "Login" >
<input type= "button" Name= "Return_index" value= "return home" onclick= "form1.action=". /include/goto_page.php3?dist_page=.. /main.php3 '; Form1.submit (); >
</div>
</td>
</tr>
</table>
</td>
</tr>
</table>
</form>
<?php
if ($error _message) echo "<center><font color= ' #ff0000 ' > $error _message</font></center>";
?>
<script language= "JavaScript" >document.form1.user_login.focus ();
</SCRIPT>
<p> </p>
<?php include (".. /footer.php3 ");?>
</body>


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.