Hello Jordan
I need your help.to get user IP and ISP (my plan is i will insert this to my mysql db)
I use these codes, but none of this give the IP nor ISP name.I use IE8,Firefox,Safari.Google Chrome...same result.
Now I am lost.Can you please me?
Code:<?php
echo 'This is all php test';
$isp = geoip_isp_by_name('there was a example link here');
if ($isp) {
echo 'This host IP is from ISP: ' . $isp;
}
?>
<?php
$hostname = gethostbyaddr($_SERVER['REMOTE_ADDR']);
echo $hostname;
?>
<?php
$IP=$_SERVER['REMOTE_ADDR'];
$HOST= gethostbyaddr($IP);
echo $IP;
echo $HOST;
?>
<?php
phpinfo();
?>
<?php
$test = $_SERVER['REMOTE_ADDR'];
echo $test;
?>
<?php
//Gets the IP address
$ip = getenv("REMOTE_ADDR") ;
Echo "Your IP is " . $ip;
?>
Last edited by Jordan; 08-13-2009 at 05:08 PM. Reason: Please use code tags
This will give you the IP of the user:
If it isn't, perhaps there is something wrong with your PHP/Webserver setup.Code:$IP=$_SERVER['REMOTE_ADDR'];
Jordan, thank you very very much.The code is working and it give me the ip address.
Is there any way I can get the ISP name?
Once again thank you
Filips
I'm guessing you want gethostbyaddr
PHP: gethostbyaddr - Manual
that section of the manual also has the other derivations of that family of commands.
Regards,
Phill.
this function will slow down your website!
don't try to run a gethostbyaddr for each one of your visitors! it response slow!
__________________________________________
I study Information Systems at Karlstad University when I'm not on CodeCall
Well explained. You are good teacher.
But I want to know that what if we don't close the connection?
As Orjan Says - you can end up with many 'dead' connections to your database. Worst case - Corruption of database, best case slowing of connections which can lead to not being able to connect to your database. Just as it is generally recommended to use mysql_real_escape_string to lessen the possibility of users inserting unwanted commands into your input strings.
Just get used to doing it automatically, and those open connections cannot come back to haunt you !!
Phill.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks