Thinkphp Member Login related issues

Source: Internet
Author: User
Thinkphp Member Login Issues
 
  Session_Start ();
Header (' content-type:text/html; Charset=utf-8 ');
Class Adminaction extends action{
Public Function index () {
if (isset ($_post[' username ')) {
if (isset ($_post[' username ')) &&isset ($_post[' password ']) {
$db =m ();
$select = $db->query ("SELECT * from developers where username=". $POST [' username ']. "and password=". $_post[' Password ' ]."");
if ($select) {
$_session[' admin ']=$_post[' username '];
$this->redirect (' Index/index ', ' ', 2, ' user '. $_post[' username '). ' Login Successful! ');
}else{
$this->redirect (' Index/index ', ' ', 2, ' username or password incorrect ');
}
}else{
$this->redirect (' Index/index ', ' ', 2, ' username or password cannot be empty! ');
}
}
$this->display ();
}



}
?>

This is the Adminaction code, do not know how the matter, no matter what input or not lose it prompts the user name or password is not correct, why? What's the problem?

Share to:


------Solution--------------------
Look at the SQL statements in the database query results there is no problem.
------Solution--------------------
Are you sure your SQL is right??

"SELECT * from developers where username= '". $POST [' username ']. "' and password= '". $_post[' password ']. "'"

------Solution--------------------
After the query operation, add: Echo $db->getlastsql (); exit; Print out the SQL statement and you'll know the result.
------Solution--------------------
References:
Quote: References:

After the query operation, add: Echo $db->getlastsql (); exit; Print out the SQL statement and you'll know the result.

Use this to find the problem, username no matter what I enter what can not print out, password no problem, which is the problem? I didn't find out what was wrong.

The name attribute in the form is not written correctly
------Solution--------------------
Reference:
Quote: Reference:

Quote: References:
  • 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.