Php login instance code, phplogin instance code
The examples in this article share the specific implementation code for logging on to login in php for your reference. The specific content is as follows:
<? Php require ".. /include/DBClass. php "; $ username = $ _ POST ['username']; $ password = $ _ POST ['Password']; if (empty ($ UserName) | empty ($ password) {Go_Msg ("Enter the user name and password! ",".. /Default.html "); exit;} DBConn (); $ password = md5 ($ password); $ SQL =" Select UserName, UserType, UserPass From siteuser where UserName = '". $ username. "'and UserPass = '". $ password. "'and isopen = 1"; // echo "$ SQL"; $ result = $ db-> exec_ SQL ($ SQL); $ total = mysql_num_rows ($ result ); if ($ total = 0) {DBClose (); Go_Msg ("the registered user has not passed the Administrator review or the user name and password do not match! Enter again! ",".. /Default.html "); exit;} else {$ Rs = $ db-> fetch_array ($ result); // Add a value and log on to session_register (" username "); session_register ("usertype"); $ _ SESSION ["usertype"] = $ Rs ['usertype']; $ _ SESSION ["username"] = $ username; // echo $ _ SESSION ["username"]; if ($ _ SESSION ["usertype"] = 1) {Go_Msg ("Login successful! "," Default. php "); // header ('location: http://163.com ');} if ($ _ SESSION [" usertype "] = 2) {Go_Msg (" Login successful! "," ../User2/default_1.php ");} if ($ _ SESSION [" usertype "] = 3) {Go_Msg (" Login successful! "," ../User3/default_2.php ");} // header ('location: default. php');} DBClose (); // Why do I ask hovertree.com?>
The above is all the content of this article. I hope it will help you learn PHP programming.