PHP permissions to log on, how to handle

Source: Internet
Author: User
PHP Permissions Login
Username (user): _____
Password (password): _____
Select Identity (user_id): _____ <----here is a drop-down menu with 3 values for student teachers and administrators
Data is transferred to login.php when you press submit
How to write code in login to let different ID login log in session and jump to different interface.
There is connection database code in config.php that can be called directly.
$db =mysql_connect (' localhost ', ' root ', ' 123456 ') or Die (database connection failed!) );
mysql_select_db (' Bishe ');
?>
Have not used the session, do not know how to write

------Solution--------------------
It's simple! At the beginning of the Code session_start (), initialize the session. You can assign a value to the $_session Super global variable or read it directly later.
Http://www.w3school.com.cn/php/php_sessions.asp
------Solution--------------------
Session_Start ();
...

$_session[' identity _id '] = ';


if ($_session[' identity _id ']== ' XXX ') {
Header ("location:http://www.baidu.com");
}
if ($_session[' identity _id ']== ' XXX ') {
Header ("location:http://www.google.com");
}
....


It's better to write a function.
Permissions are a big problem. No, the jump will solve it.

------Solution--------------------
Session_Start ();
if (@$_post["login"])
{
echo "";
}
Nest your own conditions in if and jump to the page you want to go to
------Solution--------------------
User authentication is done first
Get permission Word according to user's identity, save in session

All pages that require authentication are authenticated when they enter (via permission word)


------Solution--------------------
The session does not limit what you save, but it is generally stored using numbers for the sake of quick writing, resource occupancy, and so on.
discuss

Reference:
User authentication is done first
Get permission Word according to user's identity, save in session

All pages that require authentication are authenticated when they enter (via permission word)

Can the permission word only be a number? Mostly said to use usrflag=0,1,2 to verify,

------Solution--------------------
discuss

Reference:
User authentication is done first
Get permission Word according to user's identity, save in session

All pages that require authentication are authenticated when they enter (via permission word)

Can the permission word only be a number? Mostly said to use usrflag=0,1,2 to verify,

------Solution--------------------
Setting auto session in INI is also possible.
------Solution--------------------
discuss
User authentication is done first
Get permission Word according to user's identity, save in session

All pages that require authentication are authenticated when they enter (via permission word)
  • 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.