Ver Mensaje Individual
  #3 (permalink)  
Antiguo 13/09/2010, 15:41
er_rusty
 
Fecha de Ingreso: septiembre-2010
Mensajes: 5
Antigüedad: 14 años, 5 meses
Puntos: 1
Respuesta: Formulario de contacto...

Bueno, tras corregir el error anterior, usando un servidor de SMTP, ya me envía bien los correos mi formulario!!! Pero ahora me surgen dos dudas:
1.- Como consigo que una vez enviado el formulario aparezca un mensaje de GRACIAS POR RELLENAR EL FORMULARIO y a continuación se vaya solo a la pagina principal (index.html)?????
2.- Como hago para que sea obligatorio rellenar todos los campos???

Pongo el codigo de los dos archivos a continuación.

Contact.html
Código HTML:
Ver original
  1. <?xml version="1.0" encoding="utf-8" ?>
  2.  
  3. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  4. <html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en">
  5.  
  6.     <!-- BEGIN META -->
  7. <title>Formulario de Contacto</title>
  8. </head>
  9. <body >
  10. <form action="contact.php" method="post" accept-charset="utf-8" id="form_contact">     
  11.     <div>
  12.         <label for="fld_name"><span>Nombre</span></label>
  13.         <input type="text" name="name" id="fld_name" value='' />
  14.     </div>
  15.    
  16.     <div>
  17.         <label for="fld_pet"><span>Apellido</span></label>
  18.         <input type="text" name="lastname" id="fld_pet" value='' />
  19.     </div>
  20.    
  21.     <div>
  22.         <label for="fld_email"><span>Correo</span></label>
  23.         <input type="text" name="email" id="fld_email" value='' />
  24.     </div>
  25.     <div>
  26.         <label for="fld_msg"><span>Mensaje</span></label>
  27.         <textarea name="msg" id="fld_msg" cols="20" rows="8"></textarea>
  28.     </div>
  29.                    
  30.     <div id="submit"><input type="submit" value="Enviar" /></div>
  31. </form>
  32. </body>
  33. </html>

Contact.php
Código PHP:
Ver original
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <title>Contacto</title>
  6. </head>
  7.  
  8. <body>
  9. <?php
  10. $name = $_POST['name'];
  11. $email = $_POST['email'];
  12. $lastname = $_POST['lastname'];
  13.  
  14. $header = 'From: ' . $email . " \r\n";
  15. $header .= "X-Mailer: PHP/" . phpversion() . " \r\n";
  16. $header .= "Mime-Version: 1.0 \r\n";
  17. $header .= "Content-Type: text/plain";
  18.  
  19. $msg = "Este mensaje fue enviado por " . $name . ", Apellido " . $lastname . " \r\n";
  20. $msg .= "Su e-mail es: " . $email . " \r\n";
  21. $msg .= "Mensaje: " . $_POST['msg'] . " \r\n";
  22. $msg .= "Enviado el " . date('d/m/Y', time());
  23.  
  24. $asunto = 'Desde tu web de contacto';
  25.  
  26. mail($para, $asunto, utf8_decode($msg), $header);
  27.  
  28. echo '&estatus=ok&';
  29.  
  30. ?>
  31. </body>
  32. </html>

Ahora cuando envía el formulario solo aparece &estatus=ok&..... y además si le das a enviar cuando está vacio no da ningun error y manda un mail sin informacion.

Agradecería cualquier ayuda!!

Gracias!!