Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <title> Who visits my website [By SkarY]</title>
- <?php
- /*
- Who visit my website By SkarY
- */
- class count{
- var $con;
- var $tabla;
- function add(){
- #---Replace your details---
- $host = 'localhost';
- $user = 'root';
- $pwd = 'root';
- $db = 'test';
- $this -> tabla = 'counter';
- #-----------------------------
- $this -> con = mysql_connect($host,$user,$pwd) or die ("Connection failed!");
- $select_db = mysql_select_db($db,$this->con);
- $ip = $_SERVER['REMOTE_ADDR'];
- $pag = __FILE__;
- $ins = "INSERT INTO $this->tabla(ip,page) VALUES('$ip','$pag')";
- mysql_query($ins,$this -> con);
- }
- function show(){
- $mos = mysql_query("SELECT * FROM $this->tabla",$this -> con);
- $amount = mysql_num_rows($mos);
- if($amount !=0){
- echo $amount;
- }else{
- echo "1";
- }
- }
- }
- $counter = new count;
- $counter -> add();
- echo 'views: '; $counter -> show();
- ?>
- counter.sql
- USE test; -- Change the name of your bd
- CREATE TABLE counter( -- Table Name Change
- ip varchar(12),
- page text
- );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement