Home  >  Article  >  Backend Development  >  Application example of session in PHP4 - login page_PHP tutorial

Application example of session in PHP4 - login page_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 17:23:05880browse

//This script is used to enter a password for the user and determine whether 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 authority to book tickets!";
}
}
else{
$error_message="Error! Wrong username or wrong password. Please re-enter.";
}
$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");
}
?>




User login







if($error_message) echo "
$error_message
";
?>





www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/532251.htmlTechArticle//This script is used to enter a password for the user and determine whether the password is correct. //If correct, go to the welcome page. if ($login){ include("../include/config.inc.php3"); session_...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn