The administrator logon interface can also be used by common users. The younger brother is studying PHP and is currently writing a message board and admin. when using this part of php code, you can log on to the account of a common user without knowing what went wrong. I selected the admin table for the SQL statement. Why can I select the admin table even for users in the user table? Don't understand, please answer.
Admin. php code
Administrator login
1) {$ query = "select * from admin where user_name =? And password =? "; // Echo $ query; // exit; $ st = $ db-> prepare ($ query); $ rs = $ st-> execute (array ($ user_name, $ password); if ($ rs = false) {echo"
Script alert ('login failed! '); Window. location. href = 'admin. php' script
";} Else {// echo" login successful! "; Echo"
Script alert ('Administrator login successful! '); Window. location. href = 'admin _ select_neirong.php' script
";}}?>
Table structure
Admin table
User table
Reply to discussion (solution)
Add a field admin special identification you can welcome to visit personal php learning website http://www.phpthinking.com
Do I enclose admin in single quotes? Or .....
You have to log on successfully and save it to the session.
????
1. $ _ SESSION ['User _ name'] = $ user_name ;? Sentence ?? After successful login? Use
2. Common use ?? Management? Are all judged by $ _ SESSION ['User _ name? Log on ,?? Common use? What can I do after I log on? Management? Logon all? Login ?? .
?? Manage? Log on to save? To $ _ SESSION ['admin _ user_name '] under management? ? Entered? Face, judge? $ _ SESSION ['admin _ user_name '] instead of $ _ SESSION ['User _ name']
Upstairs! If the login succeeds, it will be saved to the session. otherwise, when determining whether the variables in the session exist, it will not be logged on or not. What else should I log on.
????
1. $ _ SESSION ['User _ name'] = $ user_name ;? Sentence ?? After successful login? Use
2. Common use ?? Management? Are all judged by $ _ SESSION ['User _ name? Log on ,?? Common use? What can I do after I log on? Management? Logon all? Login ?? .
?? Manage? Log on to save? To $ _ SESSION ['admin _ user_name '] under management? ? Entered? Face, judge? $ _ SESSION ['admin _ user_name '] instead of $ _ SESSION ['User _ name']
After successfully logging on to the console, add $ _ SESSION ['admin _ user_name '] = $ user_name. the management interface cannot be found .. The previous session start is removed.
????
1. $ _ SESSION ['User _ name'] = $ user_name ;? Sentence ?? After successful login? Use
2. Common use ?? Management? Are all judged by $ _ SESSION ['User _ name? Log on ,?? Common use? What can I do after I log on? Management? Logon all? Login ?? .
?? Manage? Log on to save? To $ _ SESSION ['admin _ user_name '] under management? ? Entered? Face, judge? $ _ SESSION ['admin _ user_name '] instead of $ _ SESSION ['User _ name']
After successfully logging on to the console, add $ _ SESSION ['admin _ user_name '] = $ user_name. the management interface cannot be found .. The previous session start is removed.
????
1. $ _ SESSION ['User _ name'] = $ user_name ;? Sentence ?? After successful login? Use
2. Common use ?? Management? Are all judged by $ _ SESSION ['User _ name? Log on ,?? Common use? What can I do after I log on? Management? Logon all? Login ?? .
?? Manage? Log on to save? To $ _ SESSION ['admin _ user_name '] under management? ? Entered? Face, judge? $ _ SESSION ['admin _ user_name '] instead of $ _ SESSION ['User _ name']
After successfully logging on to the console, add $ _ SESSION ['admin _ user_name '] = $ user_name. the management interface cannot be found .. The previous session start is removed.
Now, no matter what user name or password I enter, can I log on? What's wrong ??
????
1. $ _ SESSION ['User _ name'] = $ user_name ;? Sentence ?? After successful login? Use
2. Common use ?? Management? Are all judged by $ _ SESSION ['User _ name? Log on ,?? Common use? What can I do after I log on? Management? Logon all? Login ?? .
?? Manage? Log on to save? To $ _ SESSION ['admin _ user_name '] under management? ? Entered? Face, judge? $ _ SESSION ['admin _ user_name '] instead of $ _ SESSION ['User _ name']
After successfully logging on to the console, add $ _ SESSION ['admin _ user_name '] = $ user_name. the management interface cannot be found .. The previous session start is removed.
????
1. $ _ SESSION ['User _ name'] = $ user_name ;? Sentence ?? After successful login? Use
2. Common use ?? Management? Are all judged by $ _ SESSION ['User _ name? Log on ,?? Common use? What can I do after I log on? Management? Logon all? Login ?? .
?? Manage? Log on to save? To $ _ SESSION ['admin _ user_name '] under management? ? Entered? Face, judge? $ _ SESSION ['admin _ user_name '] instead of $ _ SESSION ['User _ name']
After successfully logging on to the console, add $ _ SESSION ['admin _ user_name '] = $ user_name. the management interface cannot be found .. The previous session start is removed.
Now, no matter what user name or password I enter, can I log on? What's wrong ??
Wrong. now, no matter what you enter, the js logon success box is displayed, and the logon interface is returned.