phpchick Posted December 20, 2011 Share Posted December 20, 2011 so the user is reading a story, to finish reading he has to click a link that redirects them to the signup page. <?php session_start(); $beginurl = $_SERVER['HTTP_REFERER']; $_SESSION['beginurl'] = $beginurl; echo $_SESSION['beginurl']; ?> <html> <head> </head> <body> <script type="text/javascript"><!-- location.replace("http://www.mysite.com/members/"); //--></script> </body> </html> When they get to the second page, they have to click a link that opens up a modal. this is the code that runs when they hit the register button session_start(); $beginurl = $_SESSION['beginurl']; $beginurl= (isset($_SESSION['beginurl'])) ? $_SESSION['beginurl'] : 'Error'; if( $_SESSION['status'] ='authorized') $_SESSION['$makemodal'] = 0; //sends the user to the page upon successful password credential if(!isset($_SESSION['SESS_USERID'])||(trim($_SESSION['SESS_USERID']=='admin'))) { echo '<script language="javascript">'; echo "top.location.href = $beginurl"; echo '</script>'; exit(); } Am I passing this variable correctly? and I'm not sure if the top.location.href towards the bottom is correct either, right now after I hit the register button I'm redirected to a blank page where the url is, "http://www.mysite.com/function Error() { [native code]}" Quote Link to comment https://forums.phpfreaks.com/topic/253516-redirecting-user-to-page-viewed-last-after-sign-up-trouble-passing-variable/ Share on other sites More sharing options...
Ivan Ivković Posted December 20, 2011 Share Posted December 20, 2011 *last before sign up There's a topic on this: http://www.phpfreaks.com/forums/index.php?topic=350137.15 Quote Link to comment https://forums.phpfreaks.com/topic/253516-redirecting-user-to-page-viewed-last-after-sign-up-trouble-passing-variable/#findComment-1299622 Share on other sites More sharing options...
ddubs Posted December 20, 2011 Share Posted December 20, 2011 If this is before any output is sent then you can just use: header('location: '.$beginurl); Instead of that Javascript redirect (which will break if JS is disabled on the client). Quote Link to comment https://forums.phpfreaks.com/topic/253516-redirecting-user-to-page-viewed-last-after-sign-up-trouble-passing-variable/#findComment-1299705 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.