Introduced:
We can use the program to display the current data.
Focus on two points: 1. The following code must be placed in a file with a. php extension, 2. Your server must support the MySQL database when running code on your server.
The code is as follows:
The following code is placed where you want to display the information.
<?php
EDIT this
$server = "localhost";
$db _user = "Database username";
$db _pass = "Database Password";
$database = "Database";
$timeoutseconds = 300;
STOP EDITING
$timestamp = time ();
$timeout = $timestamp-$timeoutseconds;
Mysql_connect ($server, $db _user, $db _pass);
$insert = Mysql_db_query ($database, insert into Useronline VALUES
(' $timestamp ', ' $REMOTE _addr ', ' $PHP _self ') ");
if (!) ( $insert)) {
Print "Useronline Insert Failed >";
}
$delete = Mysql_db_query ($database, "delete from Useronline WHERE timestamp< $timeout");
if (!) ( $delete)) {
Print "Useronline Delete Failed >";
}
$result = Mysql_db_query ($database, "select DISTINCT IP from useronline WHERE file= ' $PHP _self '");
if (!) ( $result)) {
Print "Useronline Select Error >";
}
$user = mysql_num_rows ($result);
Mysql_close ();
if ($user = = 1) {
Print ("$usern");
} else {
Print ("$usern");
}
?>
Finally, modify your username and passwords in MySQL