Ver Mensaje Individual
  #6 (permalink)  
Antiguo 31/03/2014, 03:05
Syst
 
Fecha de Ingreso: marzo-2014
Mensajes: 11
Antigüedad: 10 años, 1 mes
Puntos: 0
Respuesta: No me llegan todos los datos de mi formulario php

A ver si así se ve un poco más claro el error:

Código PHP:
Ver original
  1. <?php
  2. ###### No edites este archivo ######
  3.  
  4. require "config.php";
  5.  
  6. # RegisterGlobals OFF
  7.  
  8. $f_name = $_POST['f_name'];
  9. $f_mail = $_POST['f_mail'];$f_Edad = $_POST['f_Edad'];
  10. $poblacion = $_POST['poblacion'];
  11. $f_message = $_POST['f_message'];
  12. $rs = $_POST['rs'];
  13. $op = $_POST['op'];
  14.  
  15.    
  16.     $f_name = stripslashes($f_name);
  17.     $f_mail = stripslashes($f_mail);
  18.     $f_Edad = stripslashes($f_Edad);
  19.     $poblacion = stripslashes($poblacion);
  20.     $f_message = stripslashes($f_message);
  21.     $rs = stripslashes($rs);
  22.     $op = stripslashes($op);
  23. }
  24.  
  25. # comprobamos que el formulario no esté vacío
  26.  
  27. if ($f_name <> "" and $f_mail <> ""and $f_Edad <> "" and $poblacion <> "" and $f_message <> "" and $rs <> "" and (ereg("^[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*$",$f_mail))) {
  28.  
  29. // First, make sure the form was posted from a browser.
  30. // For basic web-forms, we don't care about anything
  31. // other than requests from a browser:    
  32. if(!isset($_SERVER['HTTP_USER_AGENT'])){
  33.    die("Acceso no autorizado");
  34.    exit;
  35. }
  36.  
  37. // Make sure the form was indeed POST'ed:
  38. //  (requires your html form to use: action="post")  
  39. if(!$_SERVER['REQUEST_METHOD'] == "POST"){
  40.    die("Acceso no autorizado");
  41.    exit;    
  42. }
  43.  
  44. // Where have we been posted from?
  45. $fromArray = parse_url(strtolower($_SERVER['HTTP_REFERER']));
  46.  
  47. // Test to see if the $fromArray used www to get here.
  48. $wwwUsed = strpos($fromArray['host'], "www.");
  49.  
  50. // Make sure the form was posted from an approved host name.
  51. if(!in_array(($wwwUsed === false ? $fromArray['host'] : substr(stristr($fromArray['host'], '.'), 1)), $authHosts)){    
  52.    die("Acceso no autorizado");  
  53.        exit;    
  54. }
  55.  
  56. // Pregunta antispam
  57.  
  58. if ($pregunta) {
  59. if ($rs != $respuesta) { die ("<em>¿Seguro que la respuesta es correcta? Vuelve atrás en tu navegador</em>");exit; }
  60. }
  61.  
  62. // Attempt to defend against header injections:
  63. $badStrings = array("Content-Type:",
  64.                     "MIME-Version:",
  65.                     "Content-Transfer-Encoding:",
  66.                     "bcc:",
  67.                     "Bcc:",
  68.                     "BCC:",
  69.                     "cc:",
  70.                     "Cc:",
  71.                     "CC:");
  72.  
  73. // Loop through each POST'ed value and test if it contains
  74. // one of the $badStrings:
  75. foreach($_POST as $k => $v){
  76.    foreach($badStrings as $v2){
  77.        if(strpos($v, $v2) !== false){
  78.                 die("Acceso no autorizado");
  79.                exit;
  80.        }
  81.    }
  82. }    
  83.  
  84. // Made it past spammer test, free up some memory
  85. // and continue rest of script:    
  86. unset($k, $v, $v2, $badStrings, $authHosts, $fromArray, $wwwUsed);
  87.  
  88. //contenido
  89.  
  90.    $informacion .= "\n\n------ información ------\n";
  91.  
  92.          $informacion .= "REMOTE HOST: ".$_SERVER['REMOTE_HOST']."\n";
  93.          $informacion .= "REMOTE ADDR: ".$_SERVER['REMOTE_ADDR']."\n";
  94.          $informacion .= "HTTP_X_FORWARDED_FOR: ".$_SERVER['HTTP_X_FORWARDED_FOR']."\n";
  95.          $informacion .= "HTTP_CLIENT_IP: ".$_SERVER['HTTP_CLIENT_IP']."\n";
  96.          $informacion .= "NAVEGADOR: ".$_SERVER['HTTP_USER_AGENT']."\n";
  97.  
  98.  
  99. $contenido = "$f_message
  100. $informacion
  101. ";
  102.  
  103.  
  104. mail("$email", "$prefijo $", "$contenido", "From: $f_name <$f_mail>");
  105. echo "<em>Tu mensaje ha sido enviado. En breve nos pondremos en contacto contigo, gracias.</em>";
  106. }
  107. else {
  108. if ($op<>"") { echo "<em>¡Ups! Es necesario rellenar correctamente todos los campos, gracias.</em>"; }
  109.  
  110. ?>
  111. <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
  112.   <div align="center">
  113.   <table>
  114.     <tr>
  115.       <td width="19" height="43" align="right" bgcolor="#999999">&nbsp;</td>
  116.       <td width="745" align="left" bgcolor="#999999"><strong>Nombre y Apellidos</strong>
  117.         <input name="f_name" type="text" value="<?php echo $f_name; ?>" size="60" /></td>
  118.       </tr>
  119.     <tr>
  120.       <td height="38" align="right" bgcolor="#999999">&nbsp;</td>
  121.       <td align="left" bgcolor="#999999"><strong>E-mail</strong>
  122. <input name="f_mail" type="text" value="<?php echo $f_mail; ?>" size="30" />
  123.         <strong> Edad </strong>        <input name="f_Edad" type="text" value="<?php echo $f_Edad; ?>" size="10" /></td>
  124.       </tr>
  125.     <tr>
  126.       <td height="37" align="right" bgcolor="#999999">&nbsp;</td>
  127.       <td align="left" bgcolor="#999999"><strong>Población</strong>        <input name="poblacion" type="text" value="<?php echo $poblacion; ?>" size="30" /></td>
  128.       </tr>
  129.     <tr>
  130.       <td height="243" align="right" bgcolor="#999999">&nbsp;</td>
  131.       <td align="left" bgcolor="#999999"><strong>Consulta</strong>
  132.         <p>
  133.   <textarea cols="80" rows="10" name="f_message"><?php echo $f_message; ?></textarea>
  134.         </p></td>
  135.       </tr>
  136.     <?php if ($pregunta) { ?>
  137.     <tr>
  138.       <td colspan="2" align="left" bgcolor="#999999"><?php echo $pregunta; ?> <input name="rs" type="text" value="" size="10" maxlength="10" /></td>
  139.       </tr>
  140.     <?php } else {echo "<input type='hidden' name='rs' value='rs' />";} ?>
  141.   </table>
  142.   <input type="hidden" name="op" value="ds" />
  143.   <input type="submit" value="Enviar consulta" />
  144.   </div>
  145. </form>
  146. <?php
  147. }
  148. ?>