elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado:


+  Foro de elhacker.net
|-+  Programación
| |-+  Desarrollo Web
| | |-+  PHP (Moderador: #!drvy)
| | | |-+  Ayuda en formulario de contacto
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: Ayuda en formulario de contacto  (Leído 2,349 veces)
eugeniocol

Desconectado Desconectado

Mensajes: 79


Ver Perfil
Ayuda en formulario de contacto
« en: 16 Mayo 2017, 21:40 pm »

Hola buenas.

Acabo de crear un formulario de contacto php html y detecto como pruebas que estoy haciendo que cuando en el campo de email se escribe algún correo que no sea Gmail no recibo la solicitud, he cambiado en el archivo send_from_email.php  la recepción de correo de yahoo a Gmail y este no es el problema.

 emeail.html

configuracion email.html
Código
  1. <!doctype htlm>
  2. <html lang="es">
  3.    <head>  
  4.        <title>email</title>                  
  5.        <link rel="stylesheet" type="text/css" href="email_general.css">                            
  6.        <meta name="viewport" content="width=device-width; user-scalable=no; initial-scale=1; maximun-scale=1">
  7. </head>
  8.  
  9.    <body>
  10. <br>
  11. <br>
  12. <ul class="flex-container1">
  13. <li class="item1" id="item">
  14.   <form><b>Rellenar todos los campos obligatorios *</b></form>
  15.   <form><b>antes de mandar el email.</b></form>
  16. <br>  
  17.     <form name="contactform" method="post" action="send_form_email.php">
  18. <table width="70%"> <!-- 330 PX; -->
  19. <tr>
  20. <td valign="top">
  21.  <label for="first_name">Nombre*</label>
  22. </td>
  23. <td valign="top">
  24.  <input  type="text" name="first_name" maxlength="50" size="24">
  25. </td>
  26. </tr>
  27. <tr>
  28. <td valign="top"">
  29.  <label for="last_name">Apellidos*</label>
  30. </td>
  31. <td valign="top">
  32.  <input  type="text" name="last_name" maxlength="50" size="24">
  33. </td>
  34. </tr>
  35. <tr>
  36. <td valign="top">
  37.  <label for="email">Email*</label>
  38. </td>
  39. <td valign="top">
  40.  <input  type="text" name="email" maxlength="80" size="24">
  41. </td>
  42. </tr>
  43. <tr>
  44. <td valign="top">
  45.  <label for="telephone">Telefono*</label>
  46. </td>
  47. <td valign="top">
  48.  <input  type="text" name="telephone" maxlength="30" size="24">
  49. </td>
  50. </tr>
  51. <tr>
  52. <td valign="top">
  53.  <label for="comments">Commentario*</label>
  54. </td>
  55. <td valign="top">
  56.  <textarea  name="comments" maxlength="1000" cols="25" rows="10"></textarea>
  57. </td>
  58. </tr>
  59. <tr>
  60. <td colspan="2" style="text-align:center">
  61.  <input type="submit" value="Enviar">   <a href="https://xxxxxxxxxxxxxxx.es"><b>Web Inicio</b></a>
  62. </td>
  63. </tr>
  64. </form>
  65.    </li>
  66.  
  67. </body>
  68. </htlm>
  69.  
  70.  
  71.  
  72.  

codigo php

Código
  1. <?php
  2. if(isset($_POST['email'])) {
  3.  
  4.    // EDIT THE 2 LINES BELOW AS REQUIRED
  5.    $email_to = "xxxxxxxxxxxx@yahoo.es"; /*you@yourdomain.com */
  6.    $email_subject = "xxxxxxxxxxxxxx"; /*Your email subject line */
  7.  
  8.    function died($error) {
  9.        // your error code can go here
  10.        echo "We are very sorry, but there were error(s) found with the form you submitted. ";
  11.        echo "These errors appear below.<br /><br />";
  12.        echo $error."<br /><br />";
  13.        echo "Please go back and fix these errors.<br /><br />";
  14.        die();
  15.    }
  16.  
  17.  
  18.    // validation expected data exists
  19.    if(!isset($_POST['first_name']) ||
  20.        !isset($_POST['last_name']) ||
  21.        !isset($_POST['email']) ||
  22.        !isset($_POST['telephone']) ||
  23.        !isset($_POST['comments'])) {
  24.        died('We are sorry, but there appears to be a problem with the form you submitted.');      
  25.    }
  26.  
  27.  
  28.  
  29.    $first_name = $_POST['first_name']; // required
  30.    $last_name = $_POST['last_name']; // required
  31.    $email_from = $_POST['email']; // required
  32.    $telephone = $_POST['telephone']; // not required
  33.    $comments = $_POST['comments']; // required
  34.  
  35.    $error_message = "";
  36.    $email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';
  37.  
  38.  if(!preg_match($email_exp,$email_from)) {
  39.    $error_message .= 'The Email Address you entered does not appear to be valid.<br />';
  40.  }
  41.  
  42.    $string_exp = "/^[A-Za-z .'-]+$/";
  43.  
  44.  if(!preg_match($string_exp,$first_name)) {
  45.    $error_message .= 'The First Name you entered does not appear to be valid.<br />';
  46.  }
  47.  
  48.  if(!preg_match($string_exp,$last_name)) {
  49.    $error_message .= 'The Last Name you entered does not appear to be valid.<br />';
  50.  }
  51.  
  52.  if(strlen($comments) < 2) {
  53.    $error_message .= 'The Comments you entered do not appear to be valid.<br />';
  54.  }
  55.  
  56.  if(strlen($error_message) > 0) {
  57.    died($error_message);
  58.  }
  59.  
  60.    $email_message = "Form details below.\n\n";
  61.  
  62.  
  63.    function clean_string($string) {
  64.      $bad = array("content-type","bcc:","to:","cc:","href");
  65.      return str_replace($bad,"",$string);
  66.    }
  67.  
  68.  
  69.  
  70.    $email_message .= "First Name: ".clean_string($first_name)."\n";
  71.    $email_message .= "Last Name: ".clean_string($last_name)."\n";
  72.    $email_message .= "Email: ".clean_string($email_from)."\n";
  73.    $email_message .= "Telephone: ".clean_string($telephone)."\n";
  74.    $email_message .= "Comments: ".clean_string($comments)."\n";
  75.  
  76. // create email headers
  77. $headers = 'From: '.$email_from."\r\n".
  78. 'Reply-To: '.$email_from."\r\n" .
  79. 'X-Mailer: PHP/' . phpversion();
  80. @mail($email_to, $email_subject, $email_message, $headers);  
  81. ?>
  82.  
  83. <!-- include your own success html here -->
  84.  
  85. Gracias por contactarnos. Estaremos en contacto con usted muy pronto.
  86.  
  87. <?php
  88.  
  89. }
  90. ?>

Salud2.


En línea

Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
ayuda para un formulario de contacto
PHP
mastertianmat3 2 3,170 Último mensaje 1 Septiembre 2006, 03:31 am
por Belem
[Ayuda] Formulario contacto 2
PHP
Adramelech 0 1,697 Último mensaje 27 Agosto 2008, 21:54 pm
por Adramelech
Formulario de contacto
PHP
© Shadoweps ツ 3 2,675 Último mensaje 10 Mayo 2010, 07:32 am
por © Shadoweps ツ
Formulario de Contacto
PHP
Sorke 6 3,182 Último mensaje 24 Octubre 2011, 20:29 pm
por Carluís
Ayuda en formulario de contacto
PHP
eugeniocol 4 2,974 Último mensaje 20 Mayo 2017, 15:10 pm
por eugeniocol
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines