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!
Moderator: General Moderators
HaVoC
Forum Commoner
Posts: 83 Joined: Sat Feb 07, 2004 7:20 am
Location: Smiths Falls, CA
Post
by HaVoC » Mon Mar 15, 2004 12:54 pm
Can anyone teach me how to get an IP with PHP if possible. It's for counter purposes.
TheBentinel.com
Forum Contributor
Posts: 282 Joined: Wed Mar 10, 2004 1:52 pm
Location: Columbus, Ohio
Post
by TheBentinel.com » Mon Mar 15, 2004 1:09 pm
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']);
JAM
DevNet Resident
Posts: 2101 Joined: Fri Aug 08, 2003 6:53 pm
Location: Sweden
Contact:
Post
by JAM » Mon Mar 15, 2004 1:52 pm
Already solved, but for plain interest (?) this might be interesting.
Check the $_SERVER area at the bottom...
HaVoC
Forum Commoner
Posts: 83 Joined: Sat Feb 07, 2004 7:20 am
Location: Smiths Falls, CA
Post
by HaVoC » Tue Mar 16, 2004 12:41 pm
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.
tim
DevNet Resident
Posts: 1165 Joined: Thu Feb 12, 2004 7:19 pm
Location: ohio
Post
by tim » Tue Mar 16, 2004 12:43 pm
your question has been answered:
Code: Select all
<?php
$ip = $_SERVER['REMOTE_ADDR'];
echo "your ip is $ip";
?>
HaVoC
Forum Commoner
Posts: 83 Joined: Sat Feb 07, 2004 7:20 am
Location: Smiths Falls, CA
Post
by HaVoC » Tue Mar 16, 2004 12:45 pm
Ok thanks, just wasn't sure. I thought that gave the address the site is on.
tim
DevNet Resident
Posts: 1165 Joined: Thu Feb 12, 2004 7:19 pm
Location: ohio
Post
by tim » Tue Mar 16, 2004 12:47 pm
lol you should have tried the script out, its the address to the remote user.
your welcome.