mnielsen Posted July 2, 2008 Share Posted July 2, 2008 hi, just trying to redirect my user when they login to there profile. I'm trying to do this with the follow but it's not owrking anymore. $profileID = $_SESSION['id']; header("Location: /profile.php?id=$profileID"); it worked the first few times but now its just given up all hope. Help please. Sorry rephrase. The redirection is working but it won't insert the id into the url. Quote Link to comment https://forums.phpfreaks.com/topic/112879-redirect-profile-id/ Share on other sites More sharing options...
mongoose00318 Posted July 2, 2008 Share Posted July 2, 2008 hi, just trying to redirect my user when they login to there profile. I'm trying to do this with the follow but it's not owrking anymore. $profileID = $_SESSION['id']; header("Location: /profile.php?id=$profileID"); it worked the first few times but now its just given up all hope. Help please. header("Location: /profile.php?id=$profileID"); Does that line of code need to be... header("Location: ../profile.php?id=$profileID"); ..perhaps? It is hard to tell since I can't see your file directory. Quote Link to comment https://forums.phpfreaks.com/topic/112879-redirect-profile-id/#findComment-579787 Share on other sites More sharing options...
trq Posted July 2, 2008 Share Posted July 2, 2008 The header() function by all rights requires a complete url. Quote Link to comment https://forums.phpfreaks.com/topic/112879-redirect-profile-id/#findComment-579788 Share on other sites More sharing options...
whiteboikyle Posted July 2, 2008 Share Posted July 2, 2008 Use this function.. it works better function header_sent($url){ echo "<script language=JavaScript>self.location.href='./$url'</script>"; } then do this header_sent("./profile.php?id=$profileID"); Quote Link to comment https://forums.phpfreaks.com/topic/112879-redirect-profile-id/#findComment-579906 Share on other sites More sharing options...
trq Posted July 2, 2008 Share Posted July 2, 2008 it works better In what way? Quote Link to comment https://forums.phpfreaks.com/topic/112879-redirect-profile-id/#findComment-579994 Share on other sites More sharing options...
DeanWhitehouse Posted July 2, 2008 Share Posted July 2, 2008 and what if js is disabled?? Quote Link to comment https://forums.phpfreaks.com/topic/112879-redirect-profile-id/#findComment-580012 Share on other sites More sharing options...
whiteboikyle Posted July 3, 2008 Share Posted July 3, 2008 Sorry doesn't necessarily work "better" but i have found it to be more useful if javascript is "enabled" header(); functions seem to give alot of grief.. and you always have to put the header function in the head.. and not all the time it is.. Quote Link to comment https://forums.phpfreaks.com/topic/112879-redirect-profile-id/#findComment-580539 Share on other sites More sharing options...
DeanWhitehouse Posted July 3, 2008 Share Posted July 3, 2008 unless you use ob_start(); Quote Link to comment https://forums.phpfreaks.com/topic/112879-redirect-profile-id/#findComment-580545 Share on other sites More sharing options...
miracle_potential Posted July 3, 2008 Share Posted July 3, 2008 $profileID = $_SESSION['id']; header("Location: www.fullurl.com/profile.php?id=" . $profileID); And check your using the correct cases on your session names done that a few times myself! haha Quote Link to comment https://forums.phpfreaks.com/topic/112879-redirect-profile-id/#findComment-580548 Share on other sites More sharing options...
trq Posted July 3, 2008 Share Posted July 3, 2008 header(); functions seem to give alot of grief.. and you always have to put the header function in the head.. and not all the time it is.. The header function does not need to be in the head, in fact it can't be called after any output to the browser so placing it within a html <head> will produce an error. You simply need to organise your logic properly so that header() is called prior to any output being sent. Ask yourself this. What is the point of outputting to the browser if all your going to do is redirect to another page? Exactly, there is no point. Quote Link to comment https://forums.phpfreaks.com/topic/112879-redirect-profile-id/#findComment-580569 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.