我有PHP
项目,用户可以在其中忘记时登录并申请新密码。我也有init.php
它指导用户在用新密码登录后更改密码页面。强制用户在请求新密码后更改密码
在INIT.PHP
的代码将用户重定向如下:
$current_file = explode('/', $_SERVER['SCRIPT_NAME']);
$current_file = end($current_file);
if (logged_in() === true) {
if (user_active($user_data['username']) === false) {
session_destroy();
header('Location: index.php');
exit();
}
if ($current_file !== 'user.php?p=change_password' && $user_data['password_recover'] == 1) {
header('Location: user.php?p=change_password&force');
exit();
}
}
$current_file
只给我user.php
,这是远远不够的,当然。我也试过$_SERVER['REQUEST_URI']
这给我/user.php?p=change_password
这很好。但仍然不起作用。我得到错误说The page isn't redirecting properly
所以总结一下。如果用户请求新密码,我需要将用户重定向到user.php?p=change_password&force
。
在此先感谢
它全部在数据库中完成。一旦他们请求新密码,就会有一个值从0变为1 – Vurkac