【发布时间】:2011-12-15 11:10:17
【问题描述】:
如何将静态导航系统更改为 PHP 动态导航系统,以便从其他静态 url 导航到动态 url?
例如,
以下基于会话变量的登录重定向标头将经过身份验证的用户重定向到登录页面,该页面使用存储在 Mysql 数据库中的 ID 值链接,其中 ID 是主键,对应的值为 1。
header('Location: user.php?id=' . $_SESSION['user_id']);
上面的header将用户重定向到下面的动态url,
www.anysite.com/anydirectory/user.php?id=1
那里有一个导航菜单,例如,
<a herf="user.php"> User Account</a>
<a href="setting.php">User Setting</a>
<a href="profile.php">User profile</a>
<a href="logout.php">Log Out</a>
这里是导航链接,
<a herf="user.php"> User Account</a>
本身就是用户登录成功后被重定向到如下动态链接/页面的静态登陆链接/页面,
www.anysite.com/anydirectory/user.php?id=1
现在,各个用户如何导航到链接,
www.anysite.com/anydirectory/user.php?id=1
但不是
www.anysite.com/anydirectory/user.php
来自其他导航链接,例如,
<a href="setting.php">User Setting</a>
<a href="profile.php">User Profile</a>
另外,我应该如何更改以下静态导航链接,
<a herf="user.php"> User Account</a>
<a href="setting.php">User Setting</a>
<a href="profile.php">User profile</a>
将基于会话变量的动态链接与经过身份验证的用户的相应 ID 值相关联,以便绝对链接看起来像,
www.anysite.com/anydirectory/user.php?id=1
www.anysite.com/anydirectory/setting.php?id=1
www.anysite.com/anydirectory/profile.php?id=1
因为所有静态链接都只针对经过身份验证的用户?
注意:您可以在How to redirect the users to their id specific urls/landing pages after they log in?查看登录会话
提前感谢您的帮助。
【问题讨论】:
标签: php mysql redirect navigation login-script