SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Addict picasso-trigger's Avatar
    Join Date
    Dec 2003
    Location
    somewhere out there
    Posts
    203
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    easy question from about if / else

    here is my code...

    Code:
    <?php 
    $_GET[rid];
    $_GET[ic];
    $url = HTTP_HOST;
    if ($rid =='') $rid = 999;
    if ($ic =='') $ic = 000;
    ?>
    most times, the rid comes in populated from the URL string, but sometimes it will be blank. so if its balnk, i currently set it to 999.

    here is what i want to do...

    if the rid is blank, i want to figure out which host the page is showing on. currently, host B just points to host A. host A content is always shown, even if it came from B.

    now... if rid comes in blank AND it came from host B, i want to make the rid = 1000.

    thanks for your help. this make sense?
    _________________________

  2. #2
    SitePoint Zealot Blue_Spade's Avatar
    Join Date
    May 2003
    Location
    Orlando
    Posts
    105
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Kinda hard to do this without the backend design but it sounds like the following should suit you well.

    Pull the http_referrer enviromental variable.

    Compare it to see whether it is from host a or b.

    Then do your if statements to give it the correct rid.

    -Ry
    Ryan Steel - Developer / Online Marketing
    Texas Hold Em & Omaha Strategy | Cordless Phone Reviews

  3. #3
    SitePoint Addict picasso-trigger's Avatar
    Join Date
    Dec 2003
    Location
    somewhere out there
    Posts
    203
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i need host because the same content is on multiple servers. i not concerned with the referrer

    is it on mirror hostnameA.com or hostnameB.com

    so, if rid is blank, i need the rid to reflect the host (HTTP_HOST)
    _________________________

  4. #4
    SitePoint Zealot Blue_Spade's Avatar
    Join Date
    May 2003
    Location
    Orlando
    Posts
    105
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ahh sorry misread - you are correct you will need to pull the http_host variable and run the compare.
    Ryan Steel - Developer / Online Marketing
    Texas Hold Em & Omaha Strategy | Cordless Phone Reviews

  5. #5
    SitePoint Addict picasso-trigger's Avatar
    Join Date
    Dec 2003
    Location
    somewhere out there
    Posts
    203
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ok, so why does the rid end up blank for me? eben thought he host is being pulled easily?

    Code:
    <?php 
    $_GET[rid];
    $_GET[ic];
    $_GET[HTTP_HOST];
    $url = HTTP_HOST;
    if (($rid =='') AND ($url == 'hosta.com')) {$rid = 1000;}
    if (($rid =='') AND ($url == 'hostb.com')) {$rid = 999;}
    if ($ic =='') $ic = 000;
    ?>
    _________________________

  6. #6
    SitePoint Addict picasso-trigger's Avatar
    Join Date
    Dec 2003
    Location
    somewhere out there
    Posts
    203
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    nevermind, not sure why that broke it... but i didn't need $url.

    so this is working -

    Code:
    <?php 
    $_GET[rid];
    $_GET[ic];
    $_GET[HTTP_HOST];
    if (($rid =='') AND ($HTTP_HOST == 'hosta.com')) {rid = 1000;}
    if (($rid =='') AND ($HTTP_HOST == 'hostb.com')) {rid = 999;}
    if ($ic =='') $ic = 000;
    ?>
    _________________________

  7. #7
    "Of" != "Have" bronze trophy Jeff Lange's Avatar
    Join Date
    Jan 2003
    Location
    Calgary, Canada
    Posts
    2,063
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by picasso-trigger
    nevermind, not sure why that broke it... but i didn't need $url.

    so this is working -

    Code:
      <?php 
      $_GET[rid];
      $_GET[ic];
      $_GET[HTTP_HOST];
      if (($rid =='') AND ($HTTP_HOST == 'hosta.com')) {rid = 1000;}
      if (($rid =='') AND ($HTTP_HOST == 'hostb.com')) {rid = 999;}
      if ($ic =='') $ic = 000;
      ?>
    I'm not really sure exactly what you are trying to do, but that code is all wrong...

    PHP Code:
    $rid $_GET['rid'];
      
    $ic $_GET['ic'];
      
    $HTTP_HOST $_GET['HTTP_HOST'];
      if (empty(
    $rid) AND $HTTP_HOST=='hosta.com')
        
    $rid 1000;
      if (empty(
    $rid) AND $HTTP_HOST=='hostb.com')
        
    $rid 999;
      if (empty(
    $ic)
        
    $ic 0
    As far as I can tell, that should probably do what you want...
    Who walks the stairs without a care
    It shoots so high in the sky.
    Bounce up and down just like a clown.
    Everyone knows its Slinky.

  8. #8
    SitePoint Addict picasso-trigger's Avatar
    Join Date
    Dec 2003
    Location
    somewhere out there
    Posts
    203
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i'm not a pro, but why is it wrong?
    _________________________


Bookmarks

Posting Permissions

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