Bienvenido a Tecnohackers

Tecnohackers » Programacion » Programacion Webmaster » Scripts Pre-Fabricados (Moderador: Zentraedi)
 » 

Simple contador de visitas



Autor Tema: Simple contador de visitas  (Leído 891 veces)

Desconectado Doddy

  • Veterano
  • ***
  • Mensajes: 249
  • Slow Mind
Simple contador de visitas
« en: Enero 31, 2012, 09:59:27 pm »
Un simple contador de visitas.

La clase del contador

Código: You are not allowed to view links. Register or Login
<?php

/*

Base de un contador de visitas 

V 0.1

Coded By Doddy H

*/


class contador {

public function 
start($host,$user,$pass,$db) {

if (
$test = @mysql_connect($host,$user,$pass)) {
if (
mysql_select_db($db)) {
return 
true;
}}}

public function 
end() {
$test->close;
}

public function 
instalar() {

$todo1 "create table visitas (
suma int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
PRIMARY KEY (suma));
"
;

if (
mysql_query($todo1)) {
return 
true;
}
}

public function 
desinstalar() {

if (@
mysql_query("drop table visitas")) {
return 
true;
}}

public function 
otromas() {
if (@
mysql_query("INSERT INTO visitas(suma)VALUES('NULL')")) {
return 
true;
}}

public function 
totalvisitas() {
return 
mysql_num_rows(mysql_query("select suma from visitas"));
}

}

// The End ? 

?>


Ejemplos de uso

Código: You are not allowed to view links. Register or Login
<?php 

include_once("contador.php");

$name = New contador;

$name->start("localhost","root","","contador");
//$name->instalar();
//$name->desinstalar();

$name->otromas();//funcion vital para contar la visita

$cantidad $name->totalvisitas(); //funcion para contar el total de visitas

echo "<center><h1>Total de visitas $cantidad</h1></center>";

$name->end();

// The End ?


?>

You are not allowed to view links. Register or Login

Tags:
Tags:

 


SMF 2.0.19 | SMF © 2016, Simple Machines
Paginas Afiliadas
Twitter - FaceBook - Daraxblog
Designed by Smf Personal