php - Force user to change password after requesting new password -
i have php project users can login , request new password if forget. have init.php directs user change password page after logging in new password.
the code in init.php redirect user follows:
$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 giving me user.php , not enough of course. have tried $_server['request_uri'] gives me /user.php?p=change_password fine. still not work. errors saying the page isn't redirecting properly
so sum up. need redirect user user.php?p=change_password&force if have requested new password.
thanks in advance
you might stuck in redirect loop. here's think happens:
- you manage redirect user
user.php?p=change_password&force - once you're on page, if statement containing
$current_file !== 'user.php?p=change_password'still true - hence, you're trying redirect user same page s/he on, causing redirection error
Comments
Post a Comment