Advertisement
Joaqho

Counter Visit [By SkarY]

Jan 29th, 2013
333
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.27 KB | None | 0 0
  1. <title> Who visits my website [By SkarY]</title>
  2. <?php
  3. /*
  4.    Who visit my website By SkarY
  5.                                                                                         */
  6. class count{
  7.        
  8.     var $con;
  9.     var $tabla;
  10.        
  11.     function add(){
  12.         #---Replace your details---
  13.       $host = 'localhost';
  14.         $user = 'root';
  15.         $pwd = 'root';
  16.         $db = 'test';
  17.         $this -> tabla = 'counter';
  18.         #-----------------------------
  19.       $this -> con = mysql_connect($host,$user,$pwd) or die ("Connection failed!");
  20.         $select_db = mysql_select_db($db,$this->con);
  21.         $ip = $_SERVER['REMOTE_ADDR'];
  22.         $pag = __FILE__;
  23.         $ins = "INSERT INTO $this->tabla(ip,page) VALUES('$ip','$pag')";
  24.         mysql_query($ins,$this -> con);
  25.     }
  26.    
  27.     function show(){
  28.         $mos = mysql_query("SELECT * FROM $this->tabla",$this -> con);
  29.         $amount = mysql_num_rows($mos);
  30.         if($amount !=0){
  31.             echo $amount;
  32.         }else{
  33.             echo "1";
  34.         }
  35.        
  36.     }
  37.    
  38. }
  39. $counter = new count;
  40. $counter -> add();
  41. echo 'views: '; $counter -> show();
  42. ?>
  43.  
  44.  
  45.  
  46.  
  47. counter.sql
  48.  
  49. USE test; -- Change the name of your bd
  50. CREATE TABLE counter( -- Table Name Change
  51. ip varchar(12),
  52. page text
  53. );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement