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<form name="html" action="<?php $_SERVER['PHP_SELF']; ?>" method="post">
<input type="text" name="usuario" style="background-color:#F3F781"/> <textarea name="firma" cols="35" rows="5" style="background-color:#F3F781"></textarea> <input type="submit" name="enviar" value="Enviar" />
<?php
if(isset($_POST['enviar']) && $_POST['enviar'] == 'Enviar'){
if(!empty($_POST['usuario']) && !empty($_POST['firma'])){
$usuario = htmlentities(trim($_POST['usuario']));
$firma = htmlentities(trim($_POST['firma']));
$f_hoy=getdate();
$a_hoy=$f_hoy['year']."-".$f_hoy['mon']."-".$f_hoy['mday'];
$fecha = time ();
$hora = date ( "H:i:s" , $fecha );
$sqlInsert = mysql_query("INSERT INTO TFirmar (usuario, firma, fecha, hora)
VALUES ('$usuario', '$firma', '$a_hoy', '$hora')", $link)
or die(mysql_error());
}else{
?> <font color="red"> <?php echo "Debe llenar todos los campos"; ?></font><p> <?php
}
}
$_pagi_sql = "SELECT * FROM TFirmar ORDER BY fecha DESC , hora DESC";
$_pagi_cuantos = 5;
include("paginator.inc.php");
while($row = mysql_fetch_array($_pagi_result)){
echo "Fecha: $row[fecha] ($row[hora])";
echo "<p><b>$row[usuario]
</b> dijo:
<br />". nl2br($row['firma']) ."
</p><hr />";
}
?>
<?php
echo"<p>".$_pagi_navegacion."
</p>";
?>