re direct a user to a different page

Discussion in 'PHP' started by wilburforce, Feb 16, 2007.

  1. #1
    I have a database for my members frm_status, this entry contains text as to the members status e.g member, non member.

    When my members login to their account I would like non members to be directed to a different page.

    Im really struggling on how to do this, is there some way that I could add something to the top of a page which does this?

    If member status is (get text from frm_status "non member" ) redirect to guest area
    Else do nothing …stay in member area.

    sorry for the question im so use to vb and php is blowing me way.......
     
    wilburforce, Feb 16, 2007 IP
  2. papa_face

    papa_face Notable Member

    Messages:
    2,237
    Likes Received:
    67
    Best Answers:
    1
    Trophy Points:
    285
    #2
    
    if ($frm_status == "member")
     {
     //stay on this page. rest of code
     }
    else
     {
     header('Location: somewhereelse.php');
     }
    
    PHP:
     
    papa_face, Feb 16, 2007 IP
  3. stickycarrots

    stickycarrots Peon

    Messages:
    4,513
    Likes Received:
    115
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I like what papa_face has given you, but personally, I would go the other way with it:

    
    if ($frm_status != "member") {
    header('Location: somewhereelse.php');
    }
    else {
    
    // page //
    
    }
    
    PHP:
    It doesn't matter which way you do it (both will work), but systematically (if that is word) it's how I would do it... :p
     
    stickycarrots, Feb 16, 2007 IP
  4. wilburforce

    wilburforce Peon

    Messages:
    7
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    OK tried that and im still erroring, the following code must be close I hope, any ideas will be greatful.

    'groupid' is the db field and it is a number, value Gname = "Non Member"

    <?php if ($_SESSION['groupid'] $connector != "21")
    {
    header("location: ../paper_1.php");
    }
    else
    {
    header ("location: ../login.php?ErrorMessage=".$Language['sv_member'] ['error1']);
    exit();
    }
    ?>


    i keep erroring on these lines:
    <?php if ($_SESSION['groupid'] $connector != "21")
    {
    header("location: ../paper_1.php");


    have tried:
    <?php if ($_SESSION['groupid'] != "21")

    header("location: http://www.mysite.com/paper_1.php");
     
    wilburforce, Feb 17, 2007 IP
  5. designcode

    designcode Well-Known Member

    Messages:
    738
    Likes Received:
    37
    Best Answers:
    0
    Trophy Points:
    118
    #5
    This is a parse error
    <?php if ($_SESSION['groupid'] $connector != "21")
    Code (markup):
    Do you want to check both values $connector and $_SESSION['groupid'], If so use following code

    
    <?php if ($_SESSION['groupid'] == "21" && $connector != "21")
    {
    header("location: ../paper_1.php");
    
    PHP:
     
    designcode, Feb 17, 2007 IP
  6. wilburforce

    wilburforce Peon

    Messages:
    7
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Thanks for this i think the issue may be down to the connection? eg session?
    every time no matter if i login as Full member,admin or Lifetime member (package) i always redirected to Page_1.php

    frm_groups has a field called gName

    <?php if($_SESSION['gName'] != "Life Time Member")
    {
    header ("location: ../page_1.php");
    exit();
    }
    ?>
     
    wilburforce, Feb 17, 2007 IP
  7. wilburforce

    wilburforce Peon

    Messages:
    7
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Thanks for this i think the issue may be down to the connection? eg session?
    every time no matter if i login as Full member,admin or Lifetime member (package) i always redirected to Page_1.php

    frm_groups has a field called gName

    <?php if($_SESSION['gName'] != "Life Time Member")
    {
    header ("location: ../page_1.php");
    exit();
    }
    ?>
     
    wilburforce, Feb 17, 2007 IP