Ver Mensaje Individual
  #1 (permalink)  
Antiguo 08/02/2008, 11:13
alexisfch
 
Fecha de Ingreso: septiembre-2007
Mensajes: 150
Antigüedad: 17 años, 5 meses
Puntos: 1
Exclamación Contador de Visitas On Click

Hola, tengo un formulario que incluye un contador de visitas, quiero que me marque la visita al apretar el boton submit (onclick) y no al abrir la pagina.

Gracias

Este es el formulario que hice pero no me funciona, obviamente esta en extension php, y el contador se registra en un textbox:

Código PHP:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
</SCRIPT>
<script type="text/javascript"> 
function visita2(){ 
      document.frm.visita.value = <? include("contador.php"?> 

</script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Documento sin t&iacute;tulo</title>
</head>

<body>
<strong>
<input name="visita" readonly="readonly" type="text" id="visita" size="20" />
</strong>
<input name="enviar" type="button" id="enviar" onclick="visita2();" value="enviar" />
</body>
</html>
contador.php
Código PHP:
$abre fopen($archivo"r"); 

// Leemos el contenido del archivo 

$total fread($abrefilesize($archivo)); 

// Cerramos la conexión al archivo 

fclose($abre); 

// Abrimos nuevamente el archivo 

$abre fopen($archivo"w"); 

// Sumamos 1 nueva visita 

$total $total 1

// Y reemplazamos por la nueva cantidad de visitas  

$grabar fwrite($abre$total); 

// Cerramos la conexión al archivo 

fclose($abre); 

// Imprimimos el total de visitas dándole un formato 

echo "$total" 

?> 
AYUDA PLS