PHP implementation of the login page information prompt function (example analysis)

Source: Internet
Author: User
Tags php form administrator password
This article mainly introduces the PHP implementation of the login page information prompt function, involving PHP form submission, database query, judgment and session data storage and other related operations skills, the need for friends can refer to the next

Specific as follows:

login.php:


<! DOCTYPE html>


check_login.php:


<?phpheader ("content-type:text/html; Charset=utf-8 "); Session_Start (); Initialize Session variable $username = $_post[' name ']; User name $password=md5 ($_post[' pwd ') to receive the form submission;  Receive form submission password class Chkinput//define class {var $name;  var $pwd; function Chkinput ($x, $y)//define a method {$this->name= $x;//Pass the administrator name to the class object $this->name $this->pwd= $y;//Pass the administrator password to the class object $ THIS-&GT;PWD} function Checkinput () {include ("conn.php");//Connect the database file $sql =mysql_query ("Select Username,password    From admin where Username= ' ". $this->name." ' and password= ' ". $this->pwd." ' ", $conn); $info =mysql_fetch_array ($sql);      Retrieves whether the administrator name and password are correct if ($info ==false)//If the administrator name or password is incorrect, the relevant hint message {header ("Location:login.php?error=1") pops up;    Exit      } else//If the administrator name or password is correct, jump directly to the login successful interface {header ("location:login.php?error=2"); $_session[' admin_name ']= $info [' username ']; Save the administrator name in the $_session[admin_name] variable $_session[' pwd ']= $info [' Password ']; Save the administrator name in the $_SESSION[PWD] variable}}} $obj =new Chkinput (Trim ($username), Trim ($pasSword)); Create object $obj->checkinput (); Call Class?>


conn.php:


<?phpheader ("content-type:text/html; Charset=utf-8 "); $conn = mysql_connect (" localhost "," root "," 111111 "), if (! $conn) {die  (" Connection Database Failed ". Mysql_error ());} mysql_select_db ("Design") or Die ("Database selection Failed". Mysql_error ()); mysql_query ("Set names ' Uft8 '");? >


Related recommendations:

PHP User remote Login reminder Implementation code

thinkphp Framework for user remote login Reminders

PHP implementation of user remote login reminder function code sharing

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.