Ver Mensaje Individual
  #4 (permalink)  
Antiguo 27/12/2013, 18:07
Avatar de TSG
TSG
 
Fecha de Ingreso: septiembre-2013
Ubicación: España
Mensajes: 373
Antigüedad: 10 años, 7 meses
Puntos: 9
Respuesta: Problema .PHP y formulario

Crea un archivo por ejemplo llamado: index.php y coloca este código:

Código PHP:
Ver original
  1. <form id="form1" name="form1" method="post" action="">
  2. <table width="459" border="0">
  3. <tr>
  4. <th width="115" scope="col"><div align="right">Nombre:</div></th>
  5. <th width="339" scope="col"><div align="left">
  6. <input name="Nombre" type="text" id="Nombre" />
  7. </div></th>
  8. </tr>
  9. <tr>
  10. <td><div align="right"><strong>E-mail:</strong></div></td>
  11. <td><input name="Email" type="text" id="Email" /></td>
  12. </tr>
  13. <tr>
  14. <td><div align="right"><strong>Asunto: </strong></div></td>
  15. <td><input name="Asunto" type="text" id="Asunto" /></td>
  16. </tr>
  17. <tr>
  18. <td><div align="right">
  19. <p><strong>Mensaje:</strong></p>
  20. </div></td>
  21. <td><p>
  22. <textarea name="Mensaje" cols="45" rows="12" id="Mensaje"></textarea>
  23. <center><input name="Enviar" type="submit" id="Enviar" value="Enviar" />
  24. <input name="Borrar" type="reset" id="Borrar" value="Borrar" /></center>
  25. </p>
  26. </td>
  27. </tr>
  28. </table>
  29. </form>
  30.  
  31. <?php
  32. if(isset($_POST['Enviar'])){
  33.  
  34. $Nombre = $_POST['Nombre'];
  35. $Email = $_POST['Email'];
  36. $Asunto = $_POST['Asunto'];
  37.  
  38.      if($Nombre == '' or $Email == '' or $Asunto == ''){
  39.             echo "Lo sentimos no puedes dejar los campos en blanco";
  40.      }
  41.      else{
  42.  
  43. $header = 'From: ' . $Email . " \r\n";
  44. $header .= "X-Mailer: PHP/" . phpversion() . " \r\n";
  45. $header .= "Mime-Version: 1.0 \r\n";
  46. $header .= "Content-Type: text/plain";
  47.  
  48. $mensaje = "Este mensaje fue enviado por " . $Nombre . ", y el asunto es " . $Asunto . " \r\n";
  49. $mensaje .= "Su e-mail es: " . $Email . " \r\n";
  50. $mensaje .= "Mensaje: " . $_POST['Mensaje'] . " \r\n";
  51. $mensaje .= "Enviado el " . date("d/m/y \a \l\a\s H:i:s ");
  52.  
  53. $asunto = 'Contacto desde Sunday Summer';
  54.  
  55. mail($para, $asunto, utf8_decode($mensaje), $header);
  56.  
  57. echo "Su mensaje a sido enviado correctamente" ;
  58. header("Location:http://www.sundaysummer.info/contacto2.html");
  59.       }
  60. }
  61.  
  62. ?>

Es lo mismo que tenías ante pero en un solo archivo y con un poco más de seguridad.

¡Felices fiestas!
Saludos.