New to Flash? Come join Ben in this, the first of many weekly Flash articles, as he shows us how to use Flash and PHP to show a count of users on your web site.
Dynamic Flash Part 1: Counting Users Online - Whose Online Using Flash (Page 3 of 5 )
You may have remembered a while back when we published an article entitled 'Finding How Many Users Are On Your Site With PHP'. We will be modifying this code to suit our needs.
Basically, when the code runs it will check to see if an entry for your I.P. address is already in the database and add an entry if it's not. It then counts how many distinct users (based on their I.P. address) have been on your site within the last 20 mins and spits that number out.
This time, we will start with our PHP script and MySQL database. Fire up the MySQL console window and create a database called usersOnline:
create database usersOnline; use usersOnline;
Add a table to the database with the following query:
create table usersOnline ( id int auto_increment not null, userIP varchar(20) not null, dateAdded timestamp, primary key(id), unique id(id) );
This will enable us to track our users. Next, create a new PHP file called count.php. Add the following code to count.php: