Your own php online counter for website

This is the script for online counter .It can be used in your website to display online visitors in your site.

(use with your own css to have a better look)

*How to make ?


Step 1 ==>In your php site make a database.
Note the username,password and the database name of the created database.

Step 2 ==> Now create two files sql.sql and user_online.php in your site using ftp.

Step 3 ==>Copy and paste below content to user_online.php

<?
/*

JOIN US https://m.facebook.com/groups/427625107334527
Dedicated to Our New Member Arun Raj and Okechukwu Friday
*/

session_start();
$session=session_id();
$time=time();
$time_check=$time-600;
//SET TIME 10 Minute

$host="paste mysql server name here"; //My sql Host name obtained from the host
$username="paste username of database"; // Mysql username
$password="paste password of database"; // Mysql password
$db_name="paste name of database"; // Database name
$tbl_name="user_online"; // Table name

// Connect to server and select databse
mysql_connect("$host", "$username", "$password")or die("cannot connect to server");
mysql_select_db("$db_name")or die("cannot select DB");

$sql="SELECT * FROM $tbl_name WHERE session='$session'";
$result=mysql_query($sql);

$count=mysql_num_rows($result);

if($count=="0"){
$sql1="INSERT INTO $tbl_name(session, time)VALUES('$session', '$time')";
$result1=mysql_query($sql1);
}
else {
"$sql2=UPDATE $tbl_name SET time='$time' WHERE session = '$session'";
$result2=mysql_query($sql2);
}

$sql3="SELECT * FROM $tbl_name";
$result3=mysql_query($sql3);

$count_user_online=mysql_num_rows($result3);

echo "Online ($count_user_online) ";

// if over 10 minute, delete session
$sql4="DELETE FROM $tbl_name WHERE time<$time_check";
$result4=mysql_query($sql4);

mysql_close();

// Open multiple browser page for result
?>

Step4==> Copy and paste below code to sql.sql file

CREATE TABLE `user_online` (
`session` char(100) NOT NULL default '',
`time` int(11) NOT NULL default '0'
) TYPE=MyISAM;
Step5==> Now save and again open the sql.sql file.
There will be an option in the ftp site like "create sql setup wizard". Click it
A form will appear . Fill it as given below

Name:install.php
Server:paste mysql server name
User: paste mysql username
Password:paste mysql password
Database:paste mysql database name
DROP:Yes
CREATE:Yes
INSERT:Yes
and click submit.

Now type the location of  install.php  (like http://ypoursite.com/onlin_count/install.php) in your web browser and go to the url.


== Now it is ready to use ====
if you do not see "create sql setup wizard" in your ftp client just enter the phpmyadmin of your mysql database and paste the contents of sql.sql file there and run that script.

*How to use ?


In your php site use "include" function
to display this counter.

Eg: echo'<div class="smart_coders">';include 'user_online.php';
echo'</div>';

Enjoy this counter.

Demo Here:   http://appz.x20x.ml/project/online_counter/user_online.php

                                                                                                                                           Thankz.

Comments

  1. Hey Guys !

    USA Fresh & Verified SSN Leads AVAILABLE with best connectivity
    All Leads have genuine & valid information

    **HEADERS IN LEADS**
    First Name | Last Name | SSN | Dob | DL Number |Address | State | City | Zip | Phone Number | Account Number | Bank Name

    *Price for SSN lead $2
    *You can ask for sample before any deal
    *If anyone buy in bulk, we can negotiate
    *Sampling is just for serious buyers

    ==>ACTIVE & FRESH CC FULLZ ALSO AVAILABLE<==
    ->$5 PER EACH

    ->Hope for the long term deal
    ->Interested buyers will be welcome

    **Contact 24/7**
    Whatsapp > +923172721122
    Email > leads.sellers1212@gmail.com
    Telegram > @leadsupplier
    ICQ > 752822040

    ReplyDelete

Post a Comment

Popular posts from this blog

Detect whether the browser has adblock enabled - adblock detection using javascript and html

Top forums to promote your wap / mobile sites

How to change index page title in phpbb -phpbb forum