PHP logon jump & lt ;? Phpsession_start (); include (& quot; config. php & quot;); // connect to the database $ username =$ _ POST ['user']; $ word =$ _ POST ['password']; $ userword = md5 (trim (PHP logon jump
Session_start ();
Include ("config. php"); // connect to the database
$ Username = $ _ POST ['user'];
$ Word = $ _ POST ['password'];
$ Userword = md5 (trim ($ word); // MD5 conversion password
$ Id = $ _ POST ['User _ id'];
If ($ id = "student ")
{
$ Result_psword = mysql_query ("select S_PS from STUDENT where S_ID = '$ username '");
/* While ($ rows = mysql_fetch_array ($ result_psword )){}*/
If (! $ Result_psword)
{
Echo "the user does not exist. please register first ";
Echo "script setTimeout (function () {window. location. href = '.../regist. php'}, 2000); script";
Exit;
}
Else if ($ result_psword = $ userword)
{
$ _ SESSION ['login'] = 'student ';
Echo "script window. location. href = '../student. php'; script";
}
}
No jump found after login, directly parked in the login. php page.
$ Username, $ userword, $ id are all tested with imported values.
$ Result_psword = mysql_query ("select S_PS from STUDENT where S_ID = '$ username '");
This is a problem.
$ Reslt_psword: I cannot test all the values in the test. What exactly does it contain?
($ Result_psword = $ userword) can be used to determine why this sentence does not work?
I am afraid to leave more points for future use.
------ Solution --------------------
PHP code
------ Solution --------------------
Mysql_query () returns a resource set. Therefore, it cannot be determined.
If (! $ Result_psword)
{
Echo "the user does not exist. please register first ";
Echo "script setTimeout (function () {window. location. href = '.../regist. php'}, 2000); script";
Exit;
}
= ":
If (! Mysql_num_rows ($ result_psword ))
{
Echo "the user does not exist. please register first ";
Echo "script setTimeout (function () {window. location. href = '.../regist. php'}, 2000); script";
Exit;
}
------ Solution --------------------
Http://dev.mysql.com/doc/refman/5.1/zh/index.html
------ Solution --------------------
The judgment logic is reversed.
Your
If (! $ _ SESSION ['login'] | $ _ SESSION ['login']! = 'Admin' | $ _ SESSION ['login']! = 'Instructor '| $ _ SESSION ['login']! = 'Student ')
Indicates that if one of them is set up
However, for example, when $ _ SESSION ['login'] = 'admin,
$ _ SESSION ['login']! = 'Teachers' and $ _ SESSION ['login']! = 'Student'
Will be established
Ying writing
If (! $ _ SESSION ['login'] | ($ _ SESSION ['login']! = 'Admin' & $ _ SESSION ['login']! = 'Instructor '& $ _ SESSION ['login']! = 'Student '))