Page 1 of 1
PHP IP Script
Posted: Mon Mar 15, 2004 12:54 pm
by HaVoC
Can anyone teach me how to get an IP with PHP if possible. It's for counter purposes.
Re: PHP IP Script
Posted: Mon Mar 15, 2004 1:09 pm
by TheBentinel.com
HaVoC wrote:Can anyone teach me how to get an IP with PHP if possible. It's for counter purposes.
I think you want:
$_SERVER['REMOTE_ADDR']
as in:
Code: Select all
print ("Your ip address is " . $_SERVER['REMOTE_ADDR']);
Posted: Mon Mar 15, 2004 1:52 pm
by JAM
Already solved, but for plain interest (?) this might be interesting.
Check the $_SERVER area at the bottom...
Posted: Tue Mar 16, 2004 12:41 pm
by HaVoC
Well, I've made this counter script. It will get the IP of the user, put it in the database and add 1. If the person comes back in the same day the script won't go up. All I need to know is how to get the user's IP.
Posted: Tue Mar 16, 2004 12:43 pm
by tim
your question has been answered:
Code: Select all
<?php
$ip = $_SERVER['REMOTE_ADDR'];
echo "your ip is $ip";
?>
Posted: Tue Mar 16, 2004 12:45 pm
by HaVoC
Ok thanks, just wasn't sure. I thought that gave the address the site is on.

Posted: Tue Mar 16, 2004 12:47 pm
by tim
lol you should have tried the script out, its the address to the remote user.
your welcome.
