Ver Mensaje Individual
  #1 (permalink)  
Antiguo 09/07/2012, 15:44
Eclypse05
 
Fecha de Ingreso: julio-2012
Mensajes: 11
Antigüedad: 11 años, 10 meses
Puntos: 0
Problema con formulario contacto jquery & php

Mi problema es que no me muestra el "mensaje enviado" en el documento aver si pueden ayudarme y echarle un vistazo a mi codigo y decirme que esta mal??

Código HTML:
Ver original
  1. <form name="email_frm" id="form" method="post" action="enviar-form.php" enctype="application/x-www-form-urlencoded">
  2.             <label>Su nombre completo: &nbsp;</label>
  3.             <input type="text" name="nombre" id="nombre" required="required"/>
  4.             <label>Su email: &nbsp;</label>
  5.             <input type="email" name="email" id="email" required="required"/>
  6.             <label>Su tel&eacute;fono: &nbsp;</label>
  7.             <input type="text" name="telefono" id="telefono"  required="required"/>
  8.             <label>Su comentario: &nbsp;</label>
  9.             <textarea cols="35" rows="6" required="required" name="mensaje"></textarea>
  10.             <input type="submit" name="boton_enviar" id="boton_enviar" value="Enviar"/>
  11.                         <div class="enviado">Su mensaje ha sido enviado.</div>
  12.         </form>


Código CSS:
Ver original
  1. .enviado{
  2.         color: green;
  3.         margin:10px 10px 0px 0px;
  4.         font-size: 14px;
  5.         display: none;
  6.     }

Código Javascript:
Ver original
  1. $(document).ready(function() {
  2.     $("#form").submit(function() {  
  3.         event.preventDefault();
  4.     var url = $(this).attr('action');  
  5.     var data = $(this).serialize();
  6.        
  7.             var validation = true;
  8.         if(!$("#nombre").val()){
  9.             validation = false;
  10.             $("#nombre").focus();
  11.         }
  12.         else if(!$("#email").val()){
  13.             validation = false;
  14.             $("#email").focus();
  15.         }
  16.                 else if(!$("#telefono").val()){
  17.             validation = false;
  18.             $("#telefono").focus();
  19.         }
  20.                 else if(!$("#mensaje").val()){
  21.             validation = false;
  22.             $("#mensaje").focus();
  23.         }
  24.                 if(validation==true){
  25.             $.post(url, data, function() {              
  26.                                 $('#form .enviado').fadeIn("normal");
  27.                                 $('#form')[0].reset();
  28.                         });                              
  29.                 }      
  30.     });
  31. });

Código PHP:
Ver original
  1. <?php
  2.     //Guardar los datos en variables
  3.     $dest = "[email protected]";
  4.     $nombre = $_POST['nombre'];
  5.     $asunto = $_POST['nombre'];
  6.     $email = $_POST['email'];
  7.     $telefono = $_POST['telefono'];
  8.     $mensaje = $_POST['mensaje'];
  9.    
  10.     //Cabeceras del correo
  11.     $headers = "From: $email\r\n";
  12.     $headers .= "X-Mailer: PHP5\n";
  13.     $headers .= 'MIME-Version: 1.0' . "\n";
  14.     $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; //
  15.    
  16.     //Crear el cuerpo
  17.     $cuerpo = "<strong>Nombre:</strong> ".$nombre."<br>";
  18.     $cuerpo .= "<strong>Email:</strong> ".$email."<br>";
  19.     $cuerpo .= "<strong>Telefono:</strong> ".$telefono."<br>";
  20.     $cuerpo .= "<strong>Mensaje:</strong> ".$mensaje;
  21.      
  22.     //Validación      
  23.     if(mail($dest,$asunto,$cuerpo,$headers)){
  24.  
  25.     }
  26. ?>