Ver Mensaje Individual
  #1 (permalink)  
Antiguo 07/06/2008, 19:34
magicgdl
 
Fecha de Ingreso: junio-2008
Mensajes: 3
Antigüedad: 15 años, 11 meses
Puntos: 0
Ayuda con formulario que se manda en blanco...

Hola que tal un saludo y espero me puedan ayuda.

Tengo un formulario de contacto que se valida con js, funciona bien la validacion aunque aun me falta agregarle algunas cosas pero ahorita con eso es suficiente... el problemas es que cuando ingreso a contacto.php me envia automaticamente un mail al correo que esta definido con la informacion en blanco...

les pego mi codigo.

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Contacto</title>
<script>

function valida_envia(){
//valido el nombre
if (document.fvalida.nombre.value.length==0){
alert("Tiene que escribir su nombre")
document.fvalida.nombre.focus()
return false;
}
//valido el mail
if (document.fvalida.email.value.length==0){
alert("Tiene que escribir su email")
document.fvalida.email.focus()
return false;
}

//ejemplo valida mail
if ((document.fvalida.email.value == "") ||
(document.fvalida.email.value.indexOf('@') == -1) ||
(document.fvalida.email.value.indexOf('.') == -1)) {
alert("Tu mail tiene errores")
document.fvalida.email.focus()
return false;
}

//valido el interés
if (document.fvalida.interes.selectedIndex==0){
alert("Debe seleccionar un asunto.")
document.fvalida.interes.focus()
return false;
}

//valido los comentarios
if (document.fvalida.comentarios.value.length==0){
alert("Por favor escribe tus comentarios.")
document.fvalida.nombre.focus()
return false;
}

//el formulario se envia
else
alert("Gracias por enviar tus comentarios");
document.fvalida.submit();
return true;

<?php
//Recoge las variables
$nombre = $_POST['nombre'];
$email = $_POST['email'];
$asunto = $_POST['interes'];
$contenido = $_POST['comentarios'];

//Preparando envio de correo
$De = $email;
$Para = '[email protected]';
$Cuerpo.="Nombre: $nombre\n\n";
$Cuerpo.="Comentarios:\n\n$contenido\n\n";
$Cabeceras="From: $De\r\n";
$Cabeceras.="Reply-To: $De\r\n";
$Cabeceras.="Content-type: text/plain; charset=iso-8859-1\r\n";
//enviando el mail
mail($Para, $asunto, $Cuerpo, $Cabeceras);

?>
}
</script><style type="text/css">




<style type="text/css">
<!--
body {
background-color: #000000;
}
-->
</style></head>

<body>
<table border="0" align="center">
<tr>
<th scope="col"><?php include('header.php'); ?></th>
</tr>
</table>
<table height="27" border="0" align="center">
<tr align="center" valign="top">
<th width="185" scope="col"><?php include('news.php'); ?>
<th width="564" scope="col">

<form name="fvalida" action="contacto.php" method="post">
<p>&nbsp;</p>
<table bordercolor="#FF0000">
<tr>
<td>Nombre: </td>
<td><input type="text" name="nombre" size="30" maxlength="100"></td>
</tr>
<tr>
<td>Email: </td>
<td><input type="text" name="email" size="30" maxlength="100"></td>
</tr>
<tr>
<td>Asunto:</td>
<td>
<select name=interes>
<option value="Elegir">Elegir
<option value="Queja">Queja
<option value="Sugerencia">Sugerencia
<option value="Reservar">Reservar
</select> </td>
</tr>
<tr>
<td>Comentarios:</td>
<td><textarea name="comentarios" rows="5" ></textarea></td>
</tr>
<tr>
<td>&nbsp;</td>
<td><p>&nbsp;</p>
<p>&nbsp;</p></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="button" value="Enviar" onclick="valida_envia()"></td>
</tr>
</table>

</form>


</th>
<th width="185" scope="col"><?php include('gallery.php'); ?></th>
</tr>
<tr></tr>
</table>
<table border="0" align="center">
<tr>
<th scope="col"><p>
<?php include('footer.php'); ?>
</p>
</th>
</tr>
</table>
</body>
</html>