Php+mysql to verify that the login and password are correct when logging on, MySQL logon name
Straight into the topic, first look at the PHP check the login name and password is the correct code:
<?php $servername = "server name"; $username = "account name"; $password = "password"; $dbname = "database name";? ><?php//session needs to be started first. Session_Start (); Determine if uname and PWD are assigned if (Isset ($_post[' uname ')) && isset ($_post[' pwd ')) {$name = $_post[' uname ']; $pwd = $_post[' PWD ']; Connect database $conn = new mysqli ($servername, $username, $password, $dbname); if ($conn->connect_error) {die ("Connection failed:". $conn->connect_error); }//Verify that the content matches the database's records. $sql = "SELECT * from Test_students_all WHERE (student_name= ' $name ') and (password= ' $pwd ')"; Executes the above SQL statement and assigns the result set to results. $result = $conn->query ($sql); Determine if the number of records in the result set is greater than 0 if ($result->num_rows > 0) {$_session[' user_account ') = $name; Output per row data while ($row = $result->fetch_assoc ()) {echo '' . $row [' STUDENT_NBR ']. '
' . $row [' Student_name ']. ' ('. $row [' sex ']. ')' . '
' . $row [' class ']. '
' . $row [' Major ']. '
'; //Echo ''; }} else {echo "does not have the information you want";} $conn->close (); }?>
<title>Login Check</title> <?php//Isset (XX) test if XX set the IF (Isset ($_session[' User_account ')) {echo ' Hello, '. $_session[' User_account ']; } else{echo ' visitors '; }//$conn->close ();?>
:
The above is the whole content of this article, I hope that you learn PHP programming help.
http://www.bkjia.com/PHPjc/1125887.html www.bkjia.com true http://www.bkjia.com/PHPjc/1125887.html techarticle Php+mysql Implement login to verify the login name and password is correct, MySQL login straight into the topic, first check the PHP check the login name and password is correct code: PHP $servername = "Server name ...