Learn how to make a simple ip counter for your website using PHP programing language and Mysql database.
In this tutorial you will learn how to make the tables on mysql database and how to program with examples the counter script.
1. Make a mysql database from your cpanel hosting. If you don`t know how to do that, tipe in the searchbox "how to create a mysql database"
2. Create the mysql tables in the database:
id This is the id of the counter and will be unique to each counter you may start..
count This is the actual number of times the page has been loaded..
3. Whe will make our script to automaticaly create the tables in your database:
Create a php file called "setup.php" and insert this code:
-
<?
-
-
PRIMARY KEY(id),
-
count VARCHAR(30)NOT NULL)")
-
(count) VALUES('0') ")
-
echo "<p align=center><b><font face=Verdana size=4>Counter database successfully created..";
-
?>
Modify "dbuser" & "dbpass" with your mysql database settings.
Note: Localhost is used in almost 90% case by the hosting companies, but depends. Read carefuly in your cpanel hosting or the hosting website.
4. Create the php file called "count.php" and paste this code:
Modify again the database username and password.
5. Upload all files in your web server with a ftp client and run the php file called "setup.php" to create the tables in your mysql database.
6. Now we can simply include it in any PHP file with the PHP include like:
include "PATH_TO/count.php" ; ?>
Recent Comments