Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2003
    Posts
    61

    Unanswered: a strange question :)

    is there a way to make an if statement depending on which IP is hitting my webserver?

    I want something like this (in PHP though)

    If (IP address is 192.168.0.1-192.168.0.30) {echo "hello - you are coming from my internal network";} else {"hello, you are viewing this page from the Internet";}


    Is this possible?
    Thanks very much
    Noam

  2. #2
    Join Date
    Dec 2003
    Posts
    31
    <?php
    $ip = "192.168.2.1";

    if(eregi("192\.168\.1\.[0-9]{1,3}", $ip)) {
    echo "hello - you are coming from my internal network";
    } else {
    echo "hello, you are viewing this page from the Internet";
    }
    ?>

  3. #3
    Join Date
    Jan 2004
    Posts
    7

    Re: a strange question :)

    you can get the clients ip address by reading the variable

    $_SERVER["REMOTE_ADDR"]

Posting Permissions

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