Jump to content

Page redirect help


lukep11a

Recommended Posts

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.