Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

how do i get a users ip address?

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

how do i get a users ip address?

Postby flash_harry » Wed Feb 05, 2003 6:48 am

Subject is fairly self explanitory.
I tried doin this -

$host = $REMOTE_ADDR;
print "$host";

but apparently it isn't that simple.
flash_harry
New php-forum User
New php-forum User
 
Posts: 26
Joined: Thu Jan 16, 2003 6:05 am

Postby Hadleigh » Wed Feb 05, 2003 7:38 am

Hi,

There are a great many things you can get, try putting this in a script to see the full list.

<?
phpinfo();
?>

To pull one out simply put:
<?
$ip_address=getenv(REMOTE_ADDR);
echo"$ip_address";
?>
replace REMOTE_ADDR to get the others.

regards,

Hadleigh.
Hadleigh
New php-forum User
New php-forum User
 
Posts: 32
Joined: Tue Feb 04, 2003 10:32 am
Location: UK

Postby bobaloo » Wed Feb 05, 2003 9:39 am

or you could put:

<?PHP
$ip_addy = $_SERVER['REMOTE_ADDR'];
echo $ip_addy;
?>
bobaloo
New php-forum User
New php-forum User
 
Posts: 11
Joined: Sat Feb 01, 2003 11:34 am

Postby Redcircle » Wed Feb 05, 2003 4:31 pm

just having $REMOTE_ADDR will only work if register_globals is turned on. PHP 4.2 and higher have this turned off by default.

bobaloo's example $_SERVER['REMOTE_ADDR'] should work
User avatar
Redcircle
Moderator
Moderator
 
Posts: 830
Joined: Tue Jan 21, 2003 10:42 pm
Location: Michigan USA


Return to PHP coding => General

Who is online

Users browsing this forum: No registered users and 4 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.