Ver Mensaje Individual
  #5 (permalink)  
Antiguo 12/02/2012, 10:40
Celacanto
 
Fecha de Ingreso: agosto-2008
Mensajes: 20
Antigüedad: 15 años, 8 meses
Puntos: 0
Respuesta: No se borran los input después de enviar el formulario

El código entero es una modificación de uno libre de uso (free) que he encontrado en la red y he ido modificando a mi conveniencia hasta dejarlo así:
-----------------

<head>
<!-- -->
<style type="text/css">
.texto{color:#9B111E;font-weight:bold; font-size:12px; font-family: Verdana, Arial, Helvetica, sans-serif ;}
body td,form {font-family: Verdana, Arial, Helvetica, sans-serif;font-size:11px;color:#535353;}
form input,textarea{margin-bottom:4px;font-size:11px; color:#FFFFFF; font: Verdana, Arial, Helvetica, sans-serif; font-weight:bold; background-color:#9B111E;border:1px solid #C0C0C0;}
.boton {color:#FFFFFF;height:24px;width:55px;border:1px solid #698B9A;background-color:#9B111E;font-size:12px;font-weight:bold;}
.cambio {color:#4D4D4D;height:24px;width:167px;border:1px solid #698B9A;background-color:#B0B0B0;font-size:12px;font-weight:bold;}
</style>
<!-- -->

</script>

</head>

<!-- -->
<?
error_reporting(0);
?>
<!-- -->



<?php

$mail_destino='[email protected]';



$titulo="Mensaje formulario contactar web";

//********************************************

$msg="";
$nombre_form="";
$telefono_form="";
$direccion_form="";
$ciudad_form="";
$codigopostal_form="";
$email_form="";
$mensaje_form="";


if(isset($_POST['nombre'])){

$email_form=$_POST['email'];
$nombre_form=$_POST['nombre'];
$telefono_form=$_POST['telefono'];
$direccion_form=$_POST['direccion'];
$ciudad_form=$_POST['ciudad'];
$codigopostal_form=$_POST['codigopostal'];
$mensaje_form=$_POST['mensaje'];



function verificar_spam($verificar) {
$msg="";
$palabras_prohibidas = array(
"content-type:"
,"mime-version:"
,"multipart/mixed"
,"Content-Transfer-Encoding:"
,"bcc:"
,"cc:"
,"to:"
,"http:"
,"return-path:"
,"Subject:"
,"From:"
,"Envelope-to:" );

foreach($palabras_prohibidas as $palabra) {
if(eregi($palabra, strtolower($verificar))) {
$msg.= "Se encontro una palabra no permitida <b><u>$palabra</u></b> en alguno de los campos. Revíselos, por favor.<br />";
}
}

if(preg_match("/(%0A|%0D|\\n+|\\r+)/i", $verificar) != 0) {
$msg.= "El nombre o Email no pude contener saltos de linea <br />";
}
return $msg;
}


$msg.=verificar_spam($nombre_form);
$msg.=verificar_spam($telefono_form);
$msg.=verificar_spam($direccion_form);
$msg.=verificar_spam($ciudad_form);
$msg.=verificar_spam($codigopostal_form);
$msg.=verificar_spam($email_form);
$msg.=verificar_spam($mensaje_form);


if($nombre_form != ""){
$nombre_form=trim($nombre_form);
if(!preg_match("/^[a-zA-a-záéíóúñüàèúÁÉÍÓÚ\s_]*$/ ",$nombre_form))
$msg.="**Su nombre no es válido. Revíselo, por favor <br />";
}else
$msg.="*Su nombre es obligatorio <br />";

if($telefono_form != ""){
$telefono_form=trim($telefono_form);
if(!preg_match("/^[0-9\s\+\-\.]*$/",$telefono_form))
$msg.="**Su teléfono no es válido. Revíselo, por favor <br />";
}else
$msg.="*Su teléfono es obligatorio <br />";

if(strlen($telefono_form) < 9){

$msg.="***Su telefono debe tener 9 cifras como mínimo.<br />";
}
if(strlen($telefono_form) > 15){

$msg.="***Su telefono debe tener 15 cifras como máximo.<br />";

}
$tipo=substr($telefono_form,0,1);
if ($tipo=='9')
{
$msg.= "";
}
elseif ($tipo=='6')
{
$msg.= "";



$msg.= ""; /
}
else
{
$msg.= "**Su número de teléfono debe comenzadr por 9 ó 6.<br />";
}


if($direccion_form != ""){
$direccion_form=trim($direccion_form);
if(!preg_match("/^[a-zA-Z0-9-a-zA-a-záéíóúñüàèúÁÉÍÓÚºª\/;,.:-_\s_]*$/ ",$direccion_form))
$msg.="**Su dirección no es válida. Revísela, por favor <br />";
}else
$msg.="*Su dirección es obligatoria <br />";
////

if($ciudad_form != ""){
$ciudad_form=trim($ciudad_form);
if(!preg_match("/^[a-zA-a-záéíóúñüàèúÁÉÍÓÚ\s_]*$/ ",$ciudad_form))
$msg.="**Su Ciudad no es válida. Revísela, por favor <br />";
}else
$msg.="*Su Ciudad es obligatoria <br />";

if($codigopostal_form != ""){
$codigopostal_form=trim($codigopostal_form);
if(!preg_match("/^[Z0-9\s_]*$/",$codigopostal_form))
$msg.="**Su código postal no es válido. Revíselo, por favor <br />";
}else
$msg.="*Su código postal es obligatorio <br />";

$tipo=substr($codigopostal_form,0,1);
if ($tipo=='0')
{
$msg.= "";
}

elseif ($tipo=='1')
{
$msg.= "";


}
elseif ($tipo=='2')
{

$msg.= "";
}

elseif ($tipo=='3')
{

$msg.= "";
}

elseif ($tipo=='4')
{

$msg.= "";
}
elseif ($tipo=='5')
{

$msg.= "";
}


else
{
$msg.= "**Su código postal no es válido.<br />";
}




if($email_form != "")
{
$email_form=trim($email_form);
if (!ereg("^[_a-zA-Z0-9-]+(.[_a-zA-Z0-9-]+)*@([_a-zA-Z0-9-]+.)*[a-zA-Z0-9-]{2,200}.[a-zA-Z]{2,6}$", $email_form))
$msg.="**Su E-mail es inválido. Revíselo, por favor <br />";
}else
$msg.="*Su e-mail es obligatorio <br />";



if($mensaje_form == "") $msg.="*El mensaje es obligatorio <br />";


if($msg == ""){
$headers = "MIME-Version: 1.0\r\n";
$headers .= "From: ".$email_form."\n";
$headers .= "To: ".$mail_destino."\n";
$headers .= "Reply-To: ".$email_form."\n";
$headers .= "Return-Path: ".$email_form."\n";
$headers .= "X-Priority: 1\n";
$headers .= "X-Mailer:PHP ".phpversion()."\n";
$headers .= "Content-Type: text/plain; charset=iso-8859-1";


$contenido="Te ha enviado un mensaje: ".$nombre_form.", desde el formulario de contacto de tu web \r\n";
$contenido .= "Fecha y hora de envio del mensaje:" . date("d/m/Y H:i:s") . " \r\n";

$contenido.="Su Nombre: ".$nombre_form."\r\n";
$contenido.="Su Email: ".$email_form."\r\n";
$contenido.="Su Telefono: ".$telefono_form."\r\n";
$contenido.="Su Ciudad: ".$ciudad_form."\r\n";
$contenido.="Su Mensaje: ".$mensaje_form."\r\n";
$contenido.= "La IP del remitente es: ".$_SERVER['REMOTE_ADDR']."\r\n";
$contenido.= "Navegador y Sistema Operativo son: ".$_SERVER['HTTP_USER_AGENT']."\r\n";

$contenido.= "idioma navegador usado visitante: ".$_SERVER['HTTP_ACCEPT_LANGUAGE']."\r\n";



if(mail($mail_destino, $titulo, $contenido, $headers))
{
header("location:".$_SERVER['PHP_SELF']."?ok=ok");

}
else
$msg.="Ocurrio un error al enviar el mensaje";

}

}


if(isset($_GET['ok'])) $msg.="El mensaje se ha enviado correctamente" ;
if(isset($_GET['ok'])) echo "<img src=\"correcto.jpg\" alt=\"Error {$row[titulo]}\" name=\"fotoNoticia\" align=\"middle\" width=\"20\" height=\"20\" />";




?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Formulario Contacto </title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

</head>
<body>
<table cellspacing='2' cellpadding='2'>
<tr>
<td>

<span style='font-size:11px;font-weight:bold;color:#F20000;'><?php echo $msg; ?></span>

</td>
</tr>
<tr>
<td>

<form action="<?php echo $_SERVER['enviar/PHP_SELF']?>" method='post' autocomplete="off">
<span class='texto'>* Nombre:</span><br />
<input type='text' name='nombre' size='33' value="<?php echo $nombre_form;?>"/><br />
<span class='texto'>* Teléfono:</span><br />
<input type='text' name='telefono' size='33' maxlength="20" value="<?php echo $telefono_form;?>"/><br />
<span class='texto'>* Dirección:</span><br />
<input type='text' name='direccion' size='33' value="<?php echo $direccion_form;?>"/><br />
<span class='texto'>* Ciudad:</span><br />
<input type='text' name='ciudad' size='33' value="<?php echo $ciudad_form;?>"/><br />
<span class='texto'>* Código postal:</span><br />
<input type='text' name='codigopostal' size='33' maxlength="5" value="<?php echo $codigopostal_form;?>"/><br />
<span class='texto'>* Su email:</span><br />
<input type='text' name='email' size='33' value="<?php echo $email_form;?>" /><br />
<span class='texto'>* Mensaje:</span><br />
<textarea name='mensaje' rows='10' cols='28' ><?php echo $mensaje_form;?></textarea><br />
<br />
<br />
<br />
<input type='submit' value='Enviar' class='boton' style="CURSOR: url(../cursor/rojo.cur),default;" />
</div>
</form>
</td>
</tr>
</table>
</body>
</html>
-----------------
Es un placer constatar la velocidad con que respondéis.
Gracias.