Pages

Tuesday, February 21, 2012

MAKING USER ONLINE PAGE PHP


MAKING ONLINE DATABASE USER

Go to the PhpMyAdmin page:

1 After entering PhpMyAdmin, create a database with the name db_useronline.
2 Create a table with name UserOnline by the number of field 3.
3 Set the field:

Field Type Length / Values
time INT
ip Varchar 50
data Varchar 100


A USER ONLINE PAGE

User page onlie in use to see how many users are accessing your website at the time. Follow these steps:
1 Create a new PHP page.
2 Put the script under the tag
include("connection.php");
mysql_select_db ('db_useronline');
$exit = 300;
$time = time();
$timeout = $time-$exit;
$insert = mysql_query("INSERT INTO useronline VALUES
('$time','$REMOTE_ADDR','$PHP_SELF')");
if(!($insert)) {
echo "Error> ";
}
$delete = mysql_query("DELETE FROM useronline WHERE time<$timeout");
if(!($delete)) {
echo "Error > ";
}
$result= mysql_query("SELECT DISTINCT ip FROM useronline WHERE data='$PHP_SELF'");
if(!($result)) {
echo "Error > ";
}
$user = mysql_num_rows($result);
echo "

User Online".$user;?>

3 Save and name it as useronline.php
4 Show the browser to see the results.

Source from toscripts.com/subtutor/making-user-online-page.html