How to hide parameters in php address bar

藏色散人
Release: 2023-03-05 08:48:02
Original
3227 people have browsed it

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信息,告诉他不能查看该用户的信息
}
Copy after login

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!

Related labels:
php
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!