Php mysql [track ip address of vistors to ur site]

vishal

-::-X10 Guru-::-
Community Support
Messages
5,255
Reaction score
192
Points
63
First of all create a table in MYSQL.Here the table name is IPADDRESS with 3 fields id(auto_increment) int,
ip (varchar (50)) and date(varchar or date)

Include this script in ur main index page.
<?php
include("includes/connection.php");//connection file to database
$ip=$_SERVER['REMOTE_ADDR'];
echo "<b>IP Address= $ip</b>";
echo "<br />";
$date=gmdate("F j, Y, g:i a", strtotime("+5 hours 30 minutes")); // Modify this to ur local time i.e((GMT) +5hours) or what ever ur local time changes with respect to GMT
echo gmdate("F j, Y, g:i a", strtotime("+5 hours 30 minutes"));
$query="INSERT INTO ipaddress (ipaddress,date) values('$ip','$date')";
mysql_query($query,$connection);
mysql_close($connection)

?>
 
Last edited:

Zubair

Community Leader
Community Support
Messages
8,766
Reaction score
305
Points
83
Very good...

keep posting such great tutorials...
 
Top