Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 9 of 9
  1. #1
    TrainReq
    Guest

    Run an else/if query

    Alright.. I want to run a query that says if $_SESSION['vip'] = yes ... dont do anything ...

    if vip isnt in the session than run a query that says if refferrer is
    http://site.com or http://site2.com or http://www.site3.com or http://www.site4.com

    , set $_SESSION['vip'] to yes. if not header location to http://www.google.com

    How would I go about doing that?

  • #2
    Senior Coder whizard's Avatar
    Join Date
    Jan 2005
    Location
    Philadelphia, PA, USA
    Posts
    1,662
    Thanks
    14
    Thanked 76 Times in 76 Posts
    Try this:
    PHP Code:
    if($_SESSION['vip'] != "yes")
    {
      
    $urls = array("site.com","site2.com","site3.com","site4.com");
      if(
    in_array($_SERVER['HTTP_REFERER'],$urls))
      {
        
    $_SESSION['vip'] = "yes";
      }
      else
      {
        
    header("Location: http://www.google.com");
      }

    HTH
    Dan
    PHP Tip: If you want to use short tags (<? or <?=$var) then make sure short_open_tag is set to "1". It really helps.

    Don't forget to save everyone time and mark your thread as Resolved :)

    "Also note that it is your responsibility to die() if necessary."

    DON'T USE THE MYSQL_ EXTENSION

  • #3
    TrainReq
    Guest
    I am geting an unexpected "{" around this part

    PHP Code:
        $_SESSION['vip'] = "yes";
      }
      else 
    the problem closing point is coming from between the "$_SESSION['vip'] = "yes";" and the "else"
    Last edited by TrainReq; 06-04-2007 at 04:11 AM.

  • #4
    Senior Coder whizard's Avatar
    Join Date
    Jan 2005
    Location
    Philadelphia, PA, USA
    Posts
    1,662
    Thanks
    14
    Thanked 76 Times in 76 Posts
    look at my updated code... the bracket issue was i forgot a closing paranthesis on the if statement, and the referer is fixed.. I forgot for a minute that there was a superglobal for the referer, and I was assuming that you had that defined somewhere

    Dan
    PHP Tip: If you want to use short tags (<? or <?=$var) then make sure short_open_tag is set to "1". It really helps.

    Don't forget to save everyone time and mark your thread as Resolved :)

    "Also note that it is your responsibility to die() if necessary."

    DON'T USE THE MYSQL_ EXTENSION

  • #5
    TrainReq
    Guest
    EDIT: Nvm.. i got it.
    Last edited by TrainReq; 06-04-2007 at 04:20 AM.

  • #6
    TrainReq
    Guest
    Alright.. another thing.. how do i get it to destroy or empty only the $_SESSION['id'] and not the $_SESSION['vip']
    Last edited by TrainReq; 06-04-2007 at 04:29 AM.

  • #7
    Senior Coder whizard's Avatar
    Join Date
    Jan 2005
    Location
    Philadelphia, PA, USA
    Posts
    1,662
    Thanks
    14
    Thanked 76 Times in 76 Posts
    Can you store the value of $_SESSION['vip'] in a database so that when the user logs in, it will pull the stored value?

    I think that once you destroy the session ID, it doesn't matter whether other session data was left, since PHP won't have an ID to reference it with. (I could be wrong about that)

    HTH
    Dan
    PHP Tip: If you want to use short tags (<? or <?=$var) then make sure short_open_tag is set to "1". It really helps.

    Don't forget to save everyone time and mark your thread as Resolved :)

    "Also note that it is your responsibility to die() if necessary."

    DON'T USE THE MYSQL_ EXTENSION

  • #8
    TrainReq
    Guest
    well.. is it possible to reset the value of a session or empty it? cause i dont feel like dealing with storing things in databases. That or could you go "destory session, then reset the cookie for VIP"
    Last edited by TrainReq; 06-04-2007 at 04:34 AM.

  • #9
    Senior Coder whizard's Avatar
    Join Date
    Jan 2005
    Location
    Philadelphia, PA, USA
    Posts
    1,662
    Thanks
    14
    Thanked 76 Times in 76 Posts
    You could definitely save it as a cookie... that could be a good solution

    (Of course, whenever cookies are mentioned there is always someone who brings up the point that people often have cookies turned off, or periodically delete them, so that is something to consider, although I would imagine most people who aren't involved in web dev don't even know how to turn cookies off)

    HTH
    Dan
    PHP Tip: If you want to use short tags (<? or <?=$var) then make sure short_open_tag is set to "1". It really helps.

    Don't forget to save everyone time and mark your thread as Resolved :)

    "Also note that it is your responsibility to die() if necessary."

    DON'T USE THE MYSQL_ EXTENSION


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •