Jump to content

Recommended Posts

I've kinda written myself into a corner.  I've got an include file that decides the behavior and appearance of everything in this system I'm developing.  Basically I'm trying to make it so that if a user hasn't created a profile, when they login, they have no choice but to fill one out before continuing.

In the include file, i made an If statement checking if the requirement isn't reached, redirect the browser to that page.  I had considered setting it just on the logon page, but the user should have no choice but to go there no matter where they try to go, and it's just easiest to set it in one place than many.

The problem is, the profile page layout and appearance is also set by the same include file.  Which means it also tries to redirect (to itself, forever).

What I need is a way to say

If (status==needprofile)
     {
          if (!"currenturl"=="profile.php")
               {
                   header('Location: profile.php');
               }
     }

 

Hopefully that makes sense.

 

Thanks in advance once again.

 

Link to comment
https://forums.phpfreaks.com/topic/139930-solved-if-on-this-page-do-this/
Share on other sites

Page name only:

 

If (status==needprofile)
          if (curPageName()=="profile.php")
                   header('Location: profile.php');

function curPageName() {
return substr($_SERVER["SCRIPT_NAME"],strrpos($_SERVER["SCRIPT_NAME"],"/")+1);
}

echo "The current page name is ".curPageName();
?>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.