Code: Select all
CREATE TABLE `info` (
`id` int(6) NOT NULL auto_increment,
`date` varchar(30) NOT NULL default '',
`time` varchar(11) NOT NULL default '',
`ip` varchar(15) NOT NULL default '',
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=119 ;Code: Select all
<?
//database info here
$username="username";
$password="password";
$database="db_name";
//you can change the date and time format if you want
$date=date("l F j, Y");
$time=date("g:i:s A");
$ip=$_SERVER['REMOTE_ADDR'];
//connect to database
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
//insert info into database
$query = "INSERT INTO info VALUES ('','$date','$time','$ip')";
mysql_query($query);
//close connection
mysql_close();
?><h3>Your Info:</h3><br>
<b>Date:</b><?php echo date("l F j, Y"); ?><br>
<b>Time:</b><?php echo date("g:i:s A"); ?><br>
<b>IP Address:</b><?php echo $_SERVER['REMOTE_ADDR']; ?><br><br>
<a href="users.php">Other Users Info</a>Code: Select all
<?
//database info
$username="username";
$password="password";
$database="db_name";
//connect to database and get user info
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query="SELECT * FROM info";
$result=mysql_query($query);
$num=mysql_numrows($result);
//close connection
mysql_close();
echo "<b><center>Visitor Information</b><br>$num Entries</center><br><br>";
$i=$num-1;
while ($i > -1) {
//get information
$date=mysql_result($result,$i,"date");
$time=mysql_result($result,$i,"time");
$id=mysql_result($result,$i,"id");
$ip=mysql_result($result,$i,"ip");
//show information
echo "<center><b>Date:</b> $date<br><b>Time:</b> $time<br><b>IP Address:</b> $ip<br><b>Visitor Number:</b> $id<hr width=25%><br></center>";
$i--;
}
?>Images:

