문제

I am having trouble with a redirecting a user to a certain page. I keep getting an error of "redirect loop". I know what this is, unfortunately, I do not know how to fix it. Here is my code $ setup.

//Check to see if the account is 'Active'
if (isset($_SESSION['inactive']) && $_SERVER['PHP_SELF'] != 'account-balance.php') {
    if ($_SESSION['active'] != 'Yes') {
        $_SESSION['inactive'] = TRUE;
        header('Location: account-balance.php');
    }
}

This code is in a "header.php" include file that is included on every page. What I am wanting to do is check whether or now a users account is active. If it is not active, redirect to the account-balance.php page. Any link they click on, I simply want it to redirect them back to the account-balance.php page until they make their payment. Is this possible to do?

도움이 되었습니까?

해결책

I figured it out. It is suppose to be basename($_SERVER['PHP_SELF']) to get just the current page name.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top