PHP basic E-mail form


/ Published in: PHP
Save to your folder(s)

from http://www.w3schools.com/php/php_mail.asp


Copy this code and paste it in your HTML
  1. <?php
  2. if (isset($_REQUEST['email']))
  3. //if "email" is filled out, send email
  4. {
  5. //send email
  6. $email = $_REQUEST['email'] ;
  7. $subject = $_REQUEST['subject'] ;
  8. $message = $_REQUEST['message'] ;
  9. mail("[email protected]", "Subject: $subject",
  10. $message, "From: $email" );
  11. echo "Thank you for using our mail form";
  12. }
  13. else
  14. //if "email" is not filled out, display the form
  15. {
  16. echo "<form method='post' action='mailform.php'>
  17. Email: <input name='email' type='text' /><br />
  18. Subject: <input name='subject' type='text' /><br />
  19. Message:<br />
  20. <textarea name='message' rows='15' cols='40'>
  21. </textarea><br />
  22. <input type='submit' />
  23. </form>";
  24. }
  25. ?>

URL: http://www.w3schools.com/php/php_secure_mail.asp

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.