Ver Mensaje Individual
  #37 (permalink)  
Antiguo 05/10/2009, 01:30
manupalaya
 
Fecha de Ingreso: enero-2007
Mensajes: 156
Antigüedad: 18 años
Puntos: 3
Respuesta: Formulario Completo

Hola joaowizard,
si le quito el parentesis a:
Código procesa.php:
Ver original
  1. echo $_POST['tmptxt'];
  2. echo $_POST['nombre'];
  3. echo $_POST['email'];
  4. echo $_POST['karate'];
  5. echo $_POST['ciudad'];
  6. echo $_POST['comentarios'];
  7. echo $_POST['A'];

me sale esto:

echo $_POST['tmptxt']; echo $_POST['nombre']; echo $_POST['email']; echo $_POST['karate']; echo $_POST['ciudad']; echo $_POST['comentarios']; echo $_POST['A'];

Gracias KrowMx, por interesarte, pero he quitado las comillas como me dijiste y tampoco sale. Me sale lo de siempre:
Su mensaje ha sido enviado.

Yo creo que el problema esta en el codigo de formulario. Mirar vuelvo a poner los archivos a ver si podeis probarlos vosotros en vuestro servidor, y será mucho más rápido. Gracias por vuestro apoyo!

Código formulario.php:
Ver original
  1. <html><head><title>formulario</title></head>
  2.  
  3. <body>
  4. <form name="ejemplo" action="procesa.php" method="post">
  5. <p>Nombre: <input type="text" name="Nombre" value="nombre">(obligatorio)</p>
  6. <p>email: <input type="text" name="email" value="email">(obligatorio)</p>
  7. <p><input type="radio" name="karate">Baloncesto <input type="radio" name="karate">Karate <input type="radio" name="karate">Futbol &nbsp;(obligatorio)</p>
  8. <p>Aceptas las condiciones: <input type="checkbox" name="A">Si&nbsp;&nbsp;&nbsp;(obligatorio)</p>
  9. <p>ciudad: <select name="ciudad" size="1">
  10. <option>Barcelona</option>
  11. <option>Madrid</option>
  12. <option>Sevilla</option>
  13. </select>(obligatorio)</p>
  14. <p>Comentarios: <textarea name="comentarios" rows="2"></textarea>(obligatorio)</p>
  15. <p><img src="captcha.php" width="100" height="30"></p>
  16. <p><input name="tmptxt" type="text">
  17. (obligatorio)</p>
  18. <p>
  19. <label>
  20. <input type="submit" name="button" id="button" value="Enviar">
  21. </label>
  22. </p>
  23. </form>
  24. </body>

Código procesa.php:
Ver original
  1. <?php session_start();//verifico captcha
  2. if ($_SESSION['tmptxt'] != $_POST['tmptxt']) {
  3. echo '<script>alert(Codigo CAPTCHA INVALIDO)</script>';//mensaje de error correspondiente
  4. echo '<script>location.href=javascript:history.back ()</script>';//con esto no se pierden los datos del FORM
  5. }
  6.  
  7. //**************** COMPRUEBO NOMBRE VACIO **********************
  8. if (!($_POST['nombre'])){
  9. echo '<script>alert(No deje nombre vacio)</script>';
  10. echo '<script>location.href=javascript:history.back ()</script>';
  11.  
  12. }
  13.  
  14. //**************** COMPRUEBO EMAIL VACIO Y VALIDO **********************
  15. if (!($_POST['email'])){
  16. echo '<script>alert(No deje email vacio)</script>';
  17. echo '<script>location.href=javascript:history.back ()</script>';
  18.  
  19. }
  20.  
  21. elseif(!eregi("^[a-z0-9]+([_\\.-][a-z0-9]+)*" ."@"."([a-z0-9]+([\.-][a-z0-9]+)*)+"."\\.[a-z]{2,}"."$",$_POST['email'])){
  22. echo '<script>alert(El email ingresado es inválido)</script>';
  23. echo '<script>location.href=javascript:history.back ()</script>';
  24. //acá verifico que el email sea VALIDO, que tenga la forma [email protected]
  25. }
  26.  
  27. //**************** COMPRUEBO RADIO BOTON MARCADO **********************
  28. if (!($_POST['karate'])){
  29. echo '<script>alert(No deje email vacio)</script>';
  30. echo '<script>location.href=javascript:history.back ()</script>';
  31.  
  32. }
  33.  
  34. //**************** COMPRUEBO ciudad **********************
  35. if (!($_POST['ciudad'])){
  36. echo '<script>alert(No deje ciudad vacio)</script>';
  37. echo '<script>location.href=javascript:history.back ()</script>';
  38.  
  39. }
  40.  
  41. //**************** COMPRUEBO comentarios MARCADO **********************
  42. if (!($_POST['comentarios'])){
  43. echo '<script>alert(No deje email vacio)</script>';
  44. echo '<script>location.href=javascript:history.back ()</script>';
  45.  
  46. }
  47.  
  48. //**************** COMPRUEBO si aceptó las condiciones **********************
  49. if (!($_POST['A'])){
  50. echo '<script>alert(Debe aceptar las condiciones)</script>';
  51. echo '<script>location.href=javascript:history.back ()</script>';
  52.  
  53. }
  54.  
  55. //una vez que verifique todo, pues envío el email.
  56. //Declaras hacia donde se envía el correo, el Destinatario
  57. $recipiente = "[email protected]";
  58.  
  59. //defines el Asunto del correo
  60. $asunto = "Contacto desde la Pagina WEB ";
  61.  
  62. //defines el cuerpo del mensaje
  63. $message ="nombre: ".$_POST['nombre']."<br>";
  64. $message .="email: ".$_POST['email']."<br>";
  65. $message .="preferencias: ".$_POST['karate']."<br>";
  66. $message .="ciudad: ".$_POST['ciudad']."<br>";
  67. $message .="comentarios: ".$_POST['comentarios']."<br>";
  68.  
  69. $message = stripslashes($message);
  70.  
  71. //haces los encabezados
  72. $headers = "MIME-Version: 1.0\r\n";
  73. $headers .= "Content-type:text/html; charset=iso-8859-1\r\n";
  74. $headers .= "From: $email\r\n";
  75. $headers .= "Repaly-to: $email\r\n";
  76. $headers .= "Cc: ".$_POST['email']."\r\n";//le envías una copia al remitente
  77.  
  78. //chao email!!
  79. mail($recipiente,$asunto,$message,$headers);
  80.  
  81. echo "El mensaje se envió correctamente";
  82. ?>

Código captcha.php:
Ver original
  1. <?php session_start();
  2. function captcha($length) {
  3. $pattern = "1234567890abcdefghijklmnopqrstuvwxyz";
  4. for($i=0;$i<$length;$i++) {
  5. $key .= $pattern{rand(0,50)};
  6. }
  7. return $key;
  8. }
  9.  
  10.  
  11. $_SESSION['tmptxt'] = captcha(8);
  12. $captcha = imagecreatefromgif("fondocaptcha.gif");
  13. $colText = imagecolorallocate($captcha, 0, 0, 0);
  14. imagestring($captcha, 5, 16, 7, $_SESSION['tmptxt'], $colText);
  15. header("Content-type: image/gif");
  16. imagegif($captcha);
  17. ?>