检测用户是否在自己的个人资料中? [英] Detect if the user is on their own profile?

查看:79
本文介绍了检测用户是否在自己的个人资料中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有profile.php风格的个人资料页面?id = 6(或者ID是什么)我还有一个myprofile.php页面,它们有不同的布局。说我的身份证是12,我想在转到profile.php时被重定向到myprofile.php?id = 12

我该如何去做?

谢谢

I have profile pages in the style of profile.php?id=6 (or whatever the ID is) and i also have a myprofile.php page and they have different layouts. Say my id is 12, i want to be redirected to myprofile.php when i go to profile.php?id=12
How would i go about doing that?
Thanks

推荐答案

我不确定你的概念是否正确或有建设性。我建议你没有自己的个人资料的概念,换句话说,你不必拥有特定于用户的网页。



例如,这种方法,请查看CodeProject。例如,点击

https://www.codeproject.com/script/Membership /Modify.aspx [ ^ ]



http://www.codeproject.com /script/Membership/ListContacts.aspx [ ^ ]。



每个用户通过相同的URL访问自己的数据。同时,没有什么可以阻止您为每个帐户创建一些单独的页面。如果要阻止其他用户(未经过身份验证或具有不同身份验证记录的用户)访问此类页面,则需要在服务器端生成页面内容(在您的情况下,在PHP中)并跳过敏感内容或重定向用户到另一页。在这两种情况下,您始终可以查看
I'm not sure if your concept is correct or constructive. I would suggest that you don't have a concept of "being on own profile", in other words, you don't have to have Web pages specific to a user.

For example of such approach, look at CodeProject. For example, click on
https://www.codeproject.com/script/Membership/Modify.aspx[^]
or
http://www.codeproject.com/script/Membership/ListContacts.aspx[^].

Every users access their own data through the same URL. At the same time, nothing prevents you from having some separate pages created per account. If you want to prevent other users (non-authenticated or users with different authentication record) to access such pages, you need to generate the page content on the server side (in your case, in PHP) and skip sensitive content or redirect the user to a different page. In both cases, you can always check up


_SERVER ['PHP_AUTH_USER'] 。用于创建任何每用户内容的所有功能都应该为用户记录提供用户ID和地址(例如,在用户配置文件数据库中找到)。



请请参阅: http://php.net/manual/en/features.http-auth.php [ ^ ]。



-SA
_SERVER['PHP_AUTH_USER']. All your functions used to create any per-user content should be give a user id and address to user record (say, found in a user profile database).

Please see: http://php.net/manual/en/features.http-auth.php[^].

—SA


这篇关于检测用户是否在自己的个人资料中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆