PHP logon redirection

Source: Internet
Author: User
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 '))

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.