Jump to content
#FlattenTheCurve ×
phreak3r

Redirecting user...

Recommended Posts

I am trying to redirect a user from out of a page in another directory. I may have to break the task up into two functions and just call the appropriate function. Although, I do not want to do that if I do not have to. The dir is setup like this....

 

soapbox

|-----channel

|        |------channel.php

|        |

|        |

 

With the current algorithm in the function, if the user is at soapbox/channel/channel.php/, they would (or should) be re-routed to soapbox/ where the index.php file is automatically displayed. However, the user is re-routed to soapbox/channel/index.php, which does not exist. I have var_dumped the $_SERVER['HTTP_REFERER'] variable which returns/prints NULL. Is there any other way to achieve my task before splitting up the tasks into two functions and calling the appropriate function, in the case where user's are trying to access a page in a sub-dir of soapbox and need to be routed back to soapbox/? (What a run-on!)

 

EDIT (display function):

function isLoggedIn() {
	if (!(isset($_SESSION['logged_in_user'])) && $_SERVER['HTTP_REFERER'] == 'http://localhost/soapbox/channel/channel.php') {
		header('Location: ../index.php');
	} else if (!(isset($_SESSION['logged_in_user']))) {
		//header('Location: index.php');
		var_dump($_SERVER['HTTP_REFERER']);
	}
}
Edited by phreak3r

Share this post


Link to post
Share on other sites

Use a root based path as you might not know where you are redirecting from:

header('Location: /soapbox/index.php');// same as typing http://localhost/soapbox/index.php
#header('Location: /new_page.php');
#header('Location: /index.php');
#header('Location: /soapbox/index.php');
#header('Location: /soapbox/channel/index.php');
  • Like 1

Share this post


Link to post
Share on other sites

 

Use a root based path as you might not know where you are redirecting from:

header('Location: /soapbox/index.php');// same as typing http://localhost/soapbox/index.php
#header('Location: /new_page.php');
#header('Location: /index.php');
#header('Location: /soapbox/index.php');
#header('Location: /soapbox/channel/index.php');

 

Thank you, archive! That seemed to do the trick! I had tried what you suggested above before, but with /index.php and soapbox/index.php (without the root-based path) and it wouldn't work. Thank you again archive!

Share this post


Link to post
Share on other sites

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.