Little brother in self-study PHP, currently writing a message board, write admin.php This part of the code, login with ordinary user account can also log in, do not know where the error. I choose the SQL statement is the admin table Ah, why even users in the user table can be selected? Do not understand, ask the big God answer.
admin.php Code
Admin 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 '
";} Else{//echo "Landing success!"; echo "
";}}? >
Table structure
Admin table
User table
Reply to discussion (solution)
Add a Field Admin Special logo will be welcome to visit the individual PHP learning website http://www.phpthinking.com
Would you like to enclose the admin in single quotation marks? Still is.....
You have to log in and save it to the session.
????
1. $_session[' user_name ']= $user _name; After the success of the log in?
2. Common use?? Management, all use $_session[' user_name '] is sentenced? When you log in, you are sentenced to management. Log in? The
?? The management of the login to save the $_session[' Admin_user_name '] in the management of the, to be able to enter the face, sentenced to $_session[' admin_user_name '] instead of $_session[' user_name '
Upstairs positive solution! Login success is saved to the session, or in the judgment of the variables in the conversation is not logged or not exist, that also landing do what.
????
1. $_session[' user_name ']= $user _name; After the success of the log in?
2. Common use?? Management, all use $_session[' user_name '] is sentenced? When you log in, you are sentenced to management. Log in? The
?? The management of the login to save the $_session[' Admin_user_name '] in the management of the, to be able to enter the face, sentenced to $_session[' admin_user_name '] instead of $_session[' user_name '
Great god I joined $_session[' admin_user_name ']= $user _name after successful login. The front session start is removed.
????
1. $_session[' user_name ']= $user _name; After the success of the log in?
2. Common use?? Management, all use $_session[' user_name '] is sentenced? When you log in, you are sentenced to management. Log in? The
?? The management of the login to save the $_session[' Admin_user_name '] in the management of the, to be able to enter the face, sentenced to $_session[' admin_user_name '] instead of $_session[' user_name '
Great god I joined $_session[' admin_user_name ']= $user _name after successful login. The front session start is removed.
????
1. $_session[' user_name ']= $user _name; After the success of the log in?
2. Common use?? Management, all use $_session[' user_name '] is sentenced? When you log in, you are sentenced to management. Log in? The
?? The management of the login to save the $_session[' Admin_user_name '] in the management of the, to be able to enter the face, sentenced to $_session[' admin_user_name '] instead of $_session[' user_name '
Great god I joined $_session[' admin_user_name ']= $user _name after successful login. The front session start is removed.
Now I don't care what type of username and password are you able to log in? What's wrong??
????
1. $_session[' user_name ']= $user _name; After the success of the log in?
2. Common use?? Management, all use $_session[' user_name '] is sentenced? When you log in, you are sentenced to management. Log in? The
?? The management of the login to save the $_session[' Admin_user_name '] in the management of the, to be able to enter the face, sentenced to $_session[' admin_user_name '] instead of $_session[' user_name '
Great god I joined $_session[' admin_user_name ']= $user _name after successful login. The front session start is removed.
????
1. $_session[' user_name ']= $user _name; After the success of the log in?
2. Common use?? Management, all use $_session[' user_name '] is sentenced? When you log in, you are sentenced to management. Log in? The
?? The management of the login to save the $_session[' Admin_user_name '] in the management of the, to be able to enter the face, sentenced to $_session[' admin_user_name '] instead of $_session[' user_name '
Great god I joined $_session[' admin_user_name ']= $user _name after successful login. The front session start is removed.
Now I don't care what type of username and password are you able to log in? What's wrong??
Say wrong, now is no matter what input, can pop-up JS login success box, and then back to the login interface.