shadiadiph Posted February 8, 2009 Share Posted February 8, 2009 Hi how can i get a users ip address who is viewing one of my webpages? Quote Link to comment https://forums.phpfreaks.com/topic/144343-solved-getting-the-users-ip-address/ Share on other sites More sharing options...
gevans Posted February 8, 2009 Share Posted February 8, 2009 $_SERVER['REMOTE_ADDR'] Quote Link to comment https://forums.phpfreaks.com/topic/144343-solved-getting-the-users-ip-address/#findComment-757412 Share on other sites More sharing options...
printf Posted February 8, 2009 Share Posted February 8, 2009 That will not always be filled or it will not always contain the actually client ip. Such as when a client is using a proxy or they are using many pass thru proxies. If you want to be 100% sure, then you need to check... REMOTE_ADDR (assign 2 variables [ip, op]) HTTP_CLIENT_IP (if this is set, assign op to this value) HTTP_X_FORWARDED_FOR (else if this is set, you will have to loop each ip, removing network masked ip(s) and then assigning op this value) HTTP_FROM (else if this is set, assign op to this value) in that order At the end of that, if $ip == $op, then client is using a unique ip, else if $ip != $op, client is using proxy gateway ip, (ip is shared) It important to do that when you create a (BLOCKING BY IP) so you only block that client, not the proxy because it is shared by thousands of users, (AOL,NETZero,most mobile phones,...) Quote Link to comment https://forums.phpfreaks.com/topic/144343-solved-getting-the-users-ip-address/#findComment-757432 Share on other sites More sharing options...
shadiadiph Posted February 13, 2009 Author Share Posted February 13, 2009 mm sorry guys you have both lost me there i half understand is there anywhere i can read up on this on the net? Unfortunately the country I live in English books are hard to find Quote Link to comment https://forums.phpfreaks.com/topic/144343-solved-getting-the-users-ip-address/#findComment-760956 Share on other sites More sharing options...
Q695 Posted February 13, 2009 Share Posted February 13, 2009 You could also pull all the variables on the server by using: echo "<b>_SERVER</b><br />"; foreach($_SERVER as $clave=>$valor) { echo $clave." = ".$valor."<br />"; } this also works very well for debugging, so you can see what variables are being sent by changing the variable type. Quote Link to comment https://forums.phpfreaks.com/topic/144343-solved-getting-the-users-ip-address/#findComment-761088 Share on other sites More sharing options...
Philip Posted February 13, 2009 Share Posted February 13, 2009 @OP: Typically, using $_SERVER['REMOTE_ADDR'] will give you the correct IP. <?php echo $_SERVER['REMOTE_ADDR']; ?> That'd show your IP when you visit. Printf was talking about how it can be spoofed, hidden, etc. Quote Link to comment https://forums.phpfreaks.com/topic/144343-solved-getting-the-users-ip-address/#findComment-761090 Share on other sites More sharing options...
shadiadiph Posted February 13, 2009 Author Share Posted February 13, 2009 thank you Quote Link to comment https://forums.phpfreaks.com/topic/144343-solved-getting-the-users-ip-address/#findComment-761130 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.