...

View Full Version : how to track visitors IP?



amitchouhanji
08-22-2006, 02:38 PM
Hi all.
I am having difficulty in tracking the IP addresses of visitors on my site.
How can I use the gethostbyaddr($_SERVER['REMOTE_ADDR']); function to track the visitors IP.

I want to have a template in which I press a button I should see the IP of the Visitor.

Please help me to solve this problem.

regards,
Amit Chouhan
amitchouanji@gmail.com

cubsfan
08-22-2006, 02:42 PM
Just use the $_SERVER variable. The gethostbyaddress function will try to resolve that to a hostname.




echo $_SERVER['REMOTE_ADDR'];

amitchouhanji
08-22-2006, 03:00 PM
thanx cubsfan,
can u please tell me how can I use this function in a form that i am using for PST method <form action="" method="POST">
I want to call this function when i submit it through a button.

regards,
Amit Chouhan
amitchouhanji@gmail.com

cubsfan
08-22-2006, 03:13 PM
If you only want it to show when the form is posted, check if the submit button is pressed and echo it out based on that. So if you have a submit input on your form

<input type='submit' name='submit' value='Click Me'>

then you can do




if ($_POST['submit']) {
echo $_SERVER['REMOTE_ADDR'];
}

amitchouhanji
08-22-2006, 03:18 PM
Thanx again ..
yeah it worked.
I am trying to learn more functions to track hits and Ip address of the visitors on my site.
thanx for ur time .

regards,
Amit Chouhan,
amitchouhanji@gmail.com



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum