Advertisement
Guest User

Untitled

a guest
May 16th, 2016
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.52 KB | None | 0 0
  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.  
  4. <head>
  5. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  6.  
  7. <title>Formulario</title> <!-- Aquí va el título de la página -->
  8.  
  9. </head>
  10.  
  11. <body>
  12. <?php
  13.  
  14. $Nombre = $_POST['Nombre'];
  15. $Email = $_POST['Email'];
  16. $Mensaje = $_POST['Mensaje'];
  17. $Telefono = $_POST['Telefono'];
  18.  
  19. if ($Nombre=='' || $Email=='' || $Mensaje=='' || $Telefono==''){
  20.  
  21. echo "<script>alert('Los campos marcados con * son obligatorios');location.href ='javascript:history.back()';</script>";
  22.  
  23. }else{
  24.  
  25.  
  26. require("archivosformulario/class.phpmailer.php");
  27. $mail = new PHPMailer();
  28. $mail->From = $Email;
  29. $mail->FromName = $Nombre;
  30. $mail->AddAddress("ejemplo@gmail.com"); // Dirección a la que llegaran los mensajes.
  31.  
  32. // Aquí van los datos que apareceran en el correo que reciba
  33. //adjuntamos un archivo
  34.  
  35. $mail->WordWrap = 50;
  36. $mail->IsHTML(true);
  37. $mail->Subject = "Comentarios Tiendas El Golazo";
  38. $mail->Body = "Nombre: $Nombre n<br />".
  39. "Email: $Email n<br />".
  40. "Mensaje: $Mensaje n<br />".
  41. "Telefono: $Telefono n<br />";
  42.  
  43. // Datos del servidor SMTP
  44.  
  45. $mail->IsSMTP();
  46. $mail->Host = "ssl://smtp.gmail.com:465"; // Servidor de Salida.
  47. $mail->SMTPAuth = true;
  48. $mail->Username = "ejemplo@gmail.com"; // Correo Electrónico
  49. $mail->Password = ""; // Contraseña
  50.  
  51. if ($mail->Send())
  52. echo "<script>alert('Formulario enviado exitosamente, le responderemos lo más pronto posible.');location.href ='javascript:history.back()';</script>";
  53.  
  54. else
  55. echo "<script>alert('Error al enviar el formulario');location.href ='javascript:history.back()';</script>";
  56.  
  57. }
  58. ?>
  59. </body>
  60. </html>
  61.  
  62. document.getElementById("myForm").reset();
  63.  
  64. if ($mail->Send())
  65. echo "<script>alert('Formulario enviado exitosamente, le responderemos lo más pronto posible.');location.href ='javascript:history.back()';</script>";
  66.  
  67. else
  68. echo "<script>alert('Error al enviar el formulario');location.href ='javascript:history.back()';</script>";
  69.  
  70. <script>
  71. // cuando se muestre la página
  72. window.addEventListener('pageshow', function(event) {
  73. // borra el formulario (asumiendo que sólo hay uno; si hay más, especifica su Id)
  74. document.querySelector("form").reset();
  75. });
  76. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement