Hello all,

I'm trying to use REMOTE_ADDR. So that I could create a quick poll, show the results, but and log someone's IP.

However when I try it, it only logs my proxy server's IP.
How do I get the user's IP?

I tried this script:

$theremote = $ENV{'REMOTE_ADDR'};
$theproxy = $ENV{'HTTP_X_FORWARDED_FOR'};
if ($theproxy == "") {$realipaddress = $theremote;} else {$realipaddress = $theproxy;}

But it still doesn't work, it actually logs nothing.

Would anyone know how to circumvent this problem?
Thanks

    $loginIp = $_SERVER['REMOTE_ADDR'];
    $tmp = mysql_query("SELECT * FROM blah WHERE voterIp = '$loginIp'");
    $row = mysql_num_rows($tmp);
    if $row == 0
    {
    show poll
    }
    else 
    {
    echo "You have already voted.";
    header("location: wherever.html");
    }
    
    
    

    this assumes u have a table blah that stores their votes and stores their ip's under voterIp

    works for me =)

      originally posted by celibate54
      works for me

      OK, but he's apparently got a server behind a proxy ... so would it work for you then?

      Seems to me you need to talk to whoever runs the proxy server ... 🙁

        Write a Reply...