When using php + MySQL, verify that the logon name and password are correct.
Go to the topic and check the php code to check whether the logon name and password are correct:
<? 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 '<p> '. $ row ['student _ nbr ']. '<br/> '. $ row ['student _ name']. '('. $ row ['sex']. ')'. '<br/> '. $ row ['class']. '<br/> '. $ row ['major']. '</p> '; // <p> </p> echo '<p> </p> ';}} else {echo" No information you want ";}$ conn-> close () ;}?> <! DOCTYPE html>
:
The above is all the content of this article. I hope it will help you learn php programming.