This document describes how to verify the login name and password entered by the user in the database during logon. This document describes how to verify the logon name and password in php + MySQL, if you are interested, you can refer to the "go-to-live" topic to check the correct php login name and password:
<? Php $ servername = "Server Name"; $ username = "account name"; $ password = "password"; $ dbname = "database name";?> <? Php // Session needs to be started first. Session_start (); // determines whether the uname and pwd values are assigned if (isset ($ _ POST ['uname']) & isset ($ _ POST ['pwd']) {$ name = $ _ POST ['uname']; $ pwd = $ _ POST ['pwd']; // connect to the database $ conn = new mysqli ($ servername, $ username, $ password, $ dbname); if ($ conn-> connect_error) {die ("Connection failed :". $ conn-> connect_error);} // verify whether the content matches the database record. $ SQL = "SELECT * FROM test_students_all WHERE (student_name = '$ name') AND (password =' $ pwd ')"; // execute the preceding SQL statement and assign the result set to the result. $ Result = $ conn-> query ($ SQL); // determines whether the number of records in the result set is greater than 0 if ($ result-> num_rows> 0) {$ _ SESSION ['User _ account'] = $ name; // output each row of data while ($ row = $ result-> fetch_assoc () {echo''. $ Row ['student _ nbr'].'
'. $ Row ['student _ name'].' ('. $ row ['sex'].') '.'
'. $ Row ['class'].'
'. $ Row ['major'].'
';//Echo'';}} Else {echo "no information you want" ;}$ conn-> close () ;}?>
Logon verification <? Php // isset (xx) test whether xx sets if (isset ($ _ SESSION ['User _ account']) {echo 'hello ,'. $ _ SESSION ['User _ account'];} else {echo 'tourists';} // $ conn-> close ();?>
:
The above is all the content of this article. I hope it will help you learn php programming.