Login instance code in php _ php instance-php Tutorial

Source: Internet
Author: User
Tags learn php programming
This article mainly introduces the login instance code in php, which has some reference value, interested friends can refer to the examples in this article to share with you the specific implementation code of 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.

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.