0

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?

4

1 回答 1

0

我想到了。假设是 basename($_SERVER['PHP_SELF']) 来获取当前页面名称。

于 2013-08-01T03:47:26.453 回答