Home  >  Article  >  Backend Development  >  How to hide parameters in php address bar

How to hide parameters in php address bar

藏色散人
藏色散人Original
2020-08-26 10:03:173282browse

How to hide parameters in the php address bar: first save the uid into the session after the user logs in; then give the user the session ID; finally, determine and display the currently logged in user information in "userinfo.php".

How to hide parameters in php address bar

Recommended: "PHP Video Tutorial"

Question:

The page I made with PHP, if you click on a user to view the user information, the following will appear on the URL bar: http://www.abc.com/index.php?user_id=39. You can view other users by modifying the number. .

Solution:

//首先,你得在用户登录后把uid存到session里,比如在login.php中
$_SESSION['uid'] = XXX //XXX为用户登录时给他的sessionID(和user表的uid值相同)
 
//比如在userinfo.php中
if($_SESSION['uid'] == intval($_GET['user_id'])){
    //显示当前登录用户信息
}else{
    //可以显示别的用户的信息(用$_SESSION['uid']查询user表的uid,并根据需要展示信息)
    //也可以直接给出error信息,告诉他不能查看该用户的信息
}

The above is the detailed content of How to hide parameters in php address bar. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn