lukep11a Posted July 20, 2011 Share Posted July 20, 2011 Hi, this is the code I have above the head tag for myaccount.php which is where each user is directed when they log in. Does anybody know how I can modify the code to direct to teamselections.php if 'firstlogin' = 0 or to myaccount.php if 'firstlogin' = 1. I think I need to change the "if(isset($_SESSION['firsttime']))" part but not sure. 'firstlogin' is in the 'login' table and the 'userid' from the 'login' table is set as a session variable when they login if that helps. Any help you can give me would be very much appreciated. Thanks in advance. <?php session_start(); // the default page, if it's not their first time $redirect="teamselections.php"; if(isset($_SESSION['firsttime'])){ // the session is set, so it must be their first time. // let's send them to their "first time" page ... $redirect="myaccount.php"; } // redirect them header ("location: $redirect"); ?> Link to comment https://forums.phpfreaks.com/topic/242480-page-redirect-help/ Share on other sites More sharing options...
mellis95 Posted July 20, 2011 Share Posted July 20, 2011 Are you having a specific problem with this code? You methodology looks generally okay. I would probably not use all the variables, and do this: (Not sure that it really makes much difference...) <?php session_start(); if(isset($_SESSION['firsttime'])) { header("location: teamselections.php"); } else { header("location: myaccount.php"); } ?> Also, if you have some value assigned to $_SESSION['firsttime'], you might check for that value as well as just isset. i.e.: if(isset($_SESSION['firsttime'])&&($_SESSION['firsttime']==true)) Link to comment https://forums.phpfreaks.com/topic/242480-page-redirect-help/#findComment-1245370 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.