Need urgent help with conditional echo of file

Discussion in 'PHP & Perl' started by 1link, Aug 2, 2012.

  1. 1link

    1link Registered Member

    Joined:
    Dec 9, 2008
    Messages:
    93
    Likes Received:
    196
    I want to do something like this:

    Code:
    <?php
    $ipaddress = $_SERVER["REMOTE_ADDR"];
    $content = file_get_contents('adfly.php');
    
    if ($ipaddress=='14.98.14.230')
        {
        echo $content;
        }
    ?>
    But it doesn't seems to be working, the purpose is to show ads, only to a specific group of people and turn of ads for others.

    Please help
     
  2. Zapdos

    Zapdos Power Member

    Joined:
    Oct 22, 2011
    Messages:
    597
    Likes Received:
    708
    Location:
    Eastern North Carolina
    Code:
    <?php
    $ipaddress = $_SERVER["REMOTE_ADDR"];
    if ($ipaddress=='14.98.14.230') {
        require 'adfly.php';
    }
    ?>
     
    • Thanks Thanks x 1
  3. 1link

    1link Registered Member

    Joined:
    Dec 9, 2008
    Messages:
    93
    Likes Received:
    196
    Thanks, this is what I was exactly looking for. This is why no books or computer can substitute actual people :-D

     
  4. xtr3m

    xtr3m Newbie

    Joined:
    Jan 7, 2011
    Messages:
    18
    Likes Received:
    6
    Occupation:
    Web developer
    Yep, you were echo'ing the contents of the PHP file instead of actually executing it.