amclean Posted January 8, 2009 Share Posted January 8, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/139930-solved-if-on-this-page-do-this/ Share on other sites More sharing options...
Maq Posted January 8, 2009 Share Posted January 8, 2009 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(); ?> Quote Link to comment https://forums.phpfreaks.com/topic/139930-solved-if-on-this-page-do-this/#findComment-732118 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.