Admin Login Interface Normal users can also log in

Source: Internet
Author: User
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.
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.