PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
hey, I'm looking to code a script for mulit national members, and what I would like to do is when they come to my page, they would trigger the script, and it would search the headers for the IP and translate it to the host and search the string for predifined country codes.. something like this:
<?php
$cc0 = ".mt";
$cc1 = ".nl";
//etc..
$ip = gethostbyaddress('$REMOTE_ADDR');
//code that snakes the country code from the $ip variable <-- help here
if($ip == $cc0) {
echo "Your logging in from Malta";
} else if($ip == $cc1) {
echo "Your logging in from the Netherlands";
}//etc..
?>
well hopefully you will get the picture with my example.. any help? thanks
generally looking at everything after the last dot in the hostname (if one exists) will tell you which country.. you can readily find the TLD country list online.
hey that looks cool, whats it do run on the server and traceroute the IP? I don't have rights to install anything on the server (I don't think so) but it looks great.. thanks