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: