Ver Mensaje Individual
  #1 (permalink)  
Antiguo 05/07/2010, 09:08
jawir
 
Fecha de Ingreso: marzo-2009
Mensajes: 221
Antigüedad: 15 años, 1 mes
Puntos: 0
Problema al recargar pagina

Tengo la siguiente pagina que es una especie de libro de visitas. El problema que tengo es que si inserto un mensaje lo hace correcto peor si recargo la pagina con F5 vuelve a insertarse la firma, cada vez que se recarga se inserta.
No se como hacer para controlar si se hace un reload no haga el insert
He probao con HTTP_REFERER pero no he conseguido solucionarlo.
Haber si me dais una idea



Código HTML:
Ver original
  1. <form name="html" action="<?php $_SERVER['PHP_SELF']; ?>" method="post">
  2.     <p><div align="center">
  3.     <br />
  4.     Usuario:<br />
  5.     <input type="text" name="usuario" style="background-color:#F3F781"/>
  6.     </p>
  7.     <p>
  8.     Firma:<br />
  9.     <textarea name="firma" cols="35" rows="5"  style="background-color:#F3F781"></textarea>
  10.     </p>
  11.     <input type="submit" name="enviar" value="Enviar" />
  12.     </div>
  13.  
  14.     <?php
  15.    
  16.     if(isset($_POST['enviar']) && $_POST['enviar'] == 'Enviar'){
  17.    
  18.         if(!empty($_POST['usuario']) && !empty($_POST['firma'])){
  19.        
  20.         $usuario = htmlentities(trim($_POST['usuario']));
  21.         $firma = htmlentities(trim($_POST['firma']));
  22.        
  23.         $f_hoy=getdate();
  24.         $a_hoy=$f_hoy['year']."-".$f_hoy['mon']."-".$f_hoy['mday'];
  25.        
  26.         $fecha = time ();
  27.         $hora = date ( "H:i:s" , $fecha );
  28.        
  29.         $sqlInsert = mysql_query("INSERT INTO TFirmar (usuario, firma, fecha, hora)
  30.         VALUES ('$usuario', '$firma', '$a_hoy', '$hora')", $link)
  31.         or die(mysql_error());
  32.    
  33.         }else{
  34.             ?> <font color="red"> <?php echo "Debe llenar todos los campos"; ?></font><p>
  35.             <?php
  36.         }
  37.     }
  38.    
  39.     $_pagi_sql = "SELECT * FROM TFirmar ORDER BY fecha DESC , hora DESC";
  40.  
  41.     $_pagi_cuantos = 5;
  42.     include("paginator.inc.php");
  43.  
  44.         while($row = mysql_fetch_array($_pagi_result)){
  45.  
  46.         echo "Fecha: $row[fecha] ($row[hora])";
  47.         echo "<p><b>$row[usuario]</b> dijo:<br />". nl2br($row['firma']) ."</p><hr />";
  48.  
  49.         }
  50.  
  51.     ?>
  52.     <div align="center">
  53.     <?php      
  54.         echo"<p>".$_pagi_navegacion."</p>";
  55.  
  56.     ?>
  57.     </div>
  58.  
  59. </form>