Foro de elhacker.net

Programación => PHP => Mensaje iniciado por: eugeniocol en 19 Mayo 2017, 20:44 pm



Título: Ayuda en formulario de contacto
Publicado por: eugeniocol en 19 Mayo 2017, 20:44 pm
Hola buenas.

Necesitaria un formulario de contacto que funcione en condiciones, tengo varios uno me funciona ok alojado en una web gratuita pero en otra de pago no va pufffff .

Salud2.


Título: Re: Ayuda en formulario de contacto
Publicado por: engel lex en 19 Mayo 2017, 20:51 pm
por que no va?

si funciona funciona, si no te funciona en otro hosting, el problema casi seguro no es el hosting sino tu


Título: Re: Ayuda en formulario de contacto
Publicado por: eugeniocol en 19 Mayo 2017, 21:25 pm
por que no va?

si funciona funciona, si no te funciona en otro hosting, el problema casi seguro no es el hosting sino tu

Pues por eso posteo en el foro para conseguir un formulario de contacto no conflictivo.

Salud2.


Título: Re: Ayuda en formulario de contacto
Publicado por: WIитX en 20 Mayo 2017, 03:55 am
Pues por eso posteo en el foro para conseguir un formulario de contacto no conflictivo.

Salud2.


Bueno pon el código que tienes para que podamos ayudarte por que, que un formulario funcione en un hosting y en otro hosting no funcione es muy raro será la configuración de la base de datos o no se. Pega el código para que podamos ayudarte


Título: Re: Ayuda en formulario de contacto
Publicado por: eugeniocol en 20 Mayo 2017, 15:10 pm
Bueno pon el código que tienes para que podamos ayudarte por que, que un formulario funcione en un hosting y en otro hosting no funcione es muy raro será la configuración de la base de datos o no se. Pega el código para que podamos ayudarte

ste es html :

Código
  1. <!doctype html5>
  2. <html lang="es">
  3.    <head>  
  4.        <title>email</title>                
  5.        <meta name="viewport" content="width=device-width; user-scalable=no; initial-scale=1; maximun-scale=1; minimun-scale=1">
  6. </head>
  7.  
  8.    <body>
  9. body {
  10. background-color: lightcyan;
  11. }
  12. input:required:invalid, textarea:required:invalid {
  13. border: 2px solid red;
  14. border-radius:5px;
  15. background: #E983CC;
  16. }
  17. input:required:valid, textarea:required:valid {
  18. border: 2px solid green;
  19. border-radius:5px;
  20. background: white;
  21. }
  22. input:invalid {
  23. border: 2px solid red;
  24. border-radius:5px;
  25. background: #E983CC;
  26. }
  27. input:valid {
  28. border: 2px solid green;
  29. border-radius:5px;
  30. background: white;
  31. }
  32. .boton {
  33. color: green;
  34. background-color:lightblue;
  35. }
  36.    <form name="contactform" method="post" action="email.php">
  37. <table width="360px">
  38. <tr>
  39. <td></td>
  40. <td>
  41. <h1>Contacto</h1>
  42. </td>
  43. </tr>
  44. <tr>
  45. <td valign="top">
  46.  <label for="first_name">Nombre *</label>
  47. </td>
  48. <td valign="top">
  49.  <input  title="Se necesita un nombre" type="text" name="first_name" maxlength="50" size="22" pattern="[a-zA-Zàáâäãå&#261;&#269;&#263;&#281;èéêë&#279;&#303;ìíîï&#322;&#324;òóôöõøùúûü&#371;&#363;ÿý&#380;&#378;ñç&#269;šžÀÁÄÃÅ&#260;&#262;&#268;&#278;&#280;ÈÉÊËÌÍÎÏ&#302;&#321;&#323;ÒÓÔÖÕØÙÚÛÜ&#370;&#362;ŸÝ&#379;&#377;ÑßÇŒÆ&#268;ŠŽ&#8706;ð ,.'-]{3,30}" required>
  50. </td>
  51. </tr>
  52. <tr>
  53. <td valign="top"">
  54.  <label for="last_name">Apellido *</label>
  55. </td>
  56. <td valign="top">
  57.  <input title="Se necesita un nombre" type="text" name="last_name" maxlength="50" size="22" pattern="[^0-9·]{3,30}" required>
  58. </td>
  59. </tr>
  60. <tr>
  61. <td valign="top">
  62.  <label for="email">Email *</label>
  63. </td>
  64. <td valign="top">
  65.  <input title="Se necesita un correo valido" type="email" name="email" maxlength="80" size="22" pattern="[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,3}$" required>
  66. </td>
  67. </tr>
  68. <tr>
  69. <td valign="top">
  70.  <label for="telephone ">Telefono</label>
  71. </td>
  72. <td valign="top">
  73.  <input  title="Se necesita un numero telefonico"type="text" name="telephone" maxlength="30" size="22" pattern="[0-9]{8,}">
  74. </td>
  75. </tr>
  76. <tr>
  77. <td valign="top">
  78.  <label for="comments">Mensaje *</label>
  79. </td>
  80. <td valign="top">
  81.  <textarea name="comments" minlength="8" maxlength="1000" cols="36" rows="6" required></textarea>
  82. </td>
  83. </tr>
  84. <tr>
  85. <td colspan="2" style="text-align:center">
  86.  <input class="boton" type="submit" value="Enviar">   <a href="https://xxxxxxxxxxxxxx.es"><b>Inicio Web</b></a>
  87. </td>
  88. </tr>
  89. </form>
  90.  
  91. </body>
  92. </htlm>
  93.  
  94.  
  95.  

y el sen_from_email.php

Código
  1. <?php
  2. /* Parametros para varios servidores
  3. HOTMAIL
  4. $smtp->SMTPAuth   = true;
  5. $smtp->SMTPSecure = "tls";
  6. $smtp->Host       = "smtp.live.com";
  7. $smtp->Username   = "miCuenta@outlook.com";
  8. $smtp->Password   = "miPassword";
  9. $smtp->Port       = 25;
  10.  
  11. GMAIL
  12. $smtp->SMTPAuth   = true;
  13. $smtp->SMTPSecure = "tls";
  14. $smtp->Host       = "smtp.gmail.com";
  15. $smtp->Username   = "miCuenta@gmail.com";
  16. $smtp->Password   = "miPassword";
  17. $smtp->Port       = 587;
  18.  
  19. YAHOO
  20. $smtp->SMTPAuth   = true;
  21. $smtp->SMTPSecure = "ssl";
  22. $smtp->Host       = "smtp.mail.yahoo.com";
  23. $smtp->Username   = "miCuenta@yahoo.com";
  24. $smtp->Password   = "miPassword";
  25. $smtp->Port       = 465;
  26. */
  27.  
  28. require 'PHPMailer-master/PHPMailerAutoload.php';
  29.  
  30. $mail = new PHPMailer;
  31.  
  32. // $mail->SMTPDebug = 3; // Enable verbose debug output
  33.  
  34. $enviar2 = '';
  35.  
  36. // Configurar el servidor, cambiar solo email y paasword si es de yahoo.
  37. $mail->isSMTP();                             // Set mailer to use SMTP
  38. $mail->Host = 'smtp.mail.yahoo.com';         // Specify main and backup SMTP servers
  39. $mail->SMTPAuth = true;                      // Enable SMTP authentication
  40. $mail->Username = 'xxxxxxxxxx@yahoo.es';  // SMTP username
  41. $mail->Password = 'xxxxxxxxx';               // SMTP password
  42. $mail->SMTPSecure = 'tls';                   // Enable TLS encryption, `ssl` also accepted
  43. $mail->Port = 587;                           // TCP port to connect to
  44.  
  45. // Parametros para configurar
  46. $correo = 'xxxxxxxxxxxxx@yahoo.es';
  47. $mailer = 'Mi web';
  48. $enviar1 = 'xxxxxxxxxxxxx@yahoo.es'; // Obligatorio
  49. $enviar2 = 'xxxxxxxx@gmail.com';  //Opcional, si no se usa dejar vacio entre ''
  50. $asunto = 'xxxxxxxxxxxx';
  51.  
  52. //**********************************************//
  53. // Parametros de mail.html, no tocar nada       //
  54. //**********************************************//
  55.  
  56. $first_name = $_POST['first_name']; // required
  57.    $last_name = $_POST['last_name']; // required
  58.    $email_from = $_POST['email']; // required
  59.    $telephone = $_POST['telephone']; // not required
  60.    $comments = $_POST['comments']; // required
  61.  
  62.    function clean_string($string) {
  63.      $bad = array("content-type","bcc:","to:","cc:","href");
  64.      return str_replace($bad,"",$string);
  65.    }
  66.    $email_message .= "First Name: ".clean_string($first_name)."<br>\n";
  67.    $email_message .= "Last Name: ".clean_string($last_name)."<br>\n";
  68.    $email_message .= "Email: ".clean_string($email_from)."<br>\n";
  69.    $email_message .= "Telephone: ".clean_string($telephone)."<br>\n";
  70.    $email_message .= "Comments: ".clean_string($comments)."<br>\n";
  71.  
  72. // envio de correo
  73. $mail->Sender=$correo;
  74. $mail->setFrom($correo, $mailer);
  75. $mail->addAddress($enviar1, 'Eugenio');     // Add a recipient
  76. if (!empty($enviar2)) {
  77. $mail->addAddress($enviar2, ''); // Name is optional
  78. }
  79.  
  80. // $mail->addReplyTo('info@example.com', 'Information');
  81. // $mail->addCC('cc@example.com');
  82. // $mail->addBCC('bcc@example.com');
  83.  
  84. // $mail->addAttachment('/var/tmp/file.tar.gz');         // Add attachments
  85. // $mail->addAttachment('/tmp/image.jpg', 'new.jpg');    // Optional name
  86. $mail->isHTML(true);                                  // Set email format to HTML
  87.  
  88. $mail->Subject = $asunto;
  89. $mail->Body    = $email_message;
  90. $mail->AltBody = $email_message;
  91.  
  92. if(!$mail->send()) {
  93.    echo 'Mensaje sin enviar.';
  94.    echo 'Mailer Error: ' . $mail->ErrorInfo;
  95.    phpAlert("Mensaje sin enviar!\\n\\nPHP has got an Alert Box");
  96. } else {
  97.    echo 'El mensaje fue enviado';
  98.    phpAlert("Mensaje enviado!\\n\\n");
  99.    header ('Refresh: 5; URL=email.html');
  100. }
  101. function phpAlert($msg) {
  102.    echo '<script type="text/javascript">alert("' . $msg . '")</script>';
  103. }
  104.  

Y después esta la carpeta PHPMailer-Master pero de esta yo no he tocado nada

Un Saludo.