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->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