0006mathew

phpemail

Apr 6th, 2016
35
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. <?php
  2. if(isset($_POST['submit'])){
  3. $to = "[email protected]"; // this is your Email address
  4. $from = $_POST['email']; // this is the sender's Email address
  5. $first_name = $_POST['first_name'];
  6. $last_name = $_POST['last_name'];
  7. $subject = "Form submission";
  8. $message = $first_name . " " . $last_name . " wrote the following:" . "\n\n" . $_POST['message'];
  9.  
  10. $headers = "From:" . $from;
  11. mail($to,$subject,$message,$headers);
  12. echo "Mail Sent. Thank you " . $first_name . ", we will contact you shortly.";
  13. // You can also use header('Location: thank_you.php'); to redirect to another page.
  14. }
  15. ?>
  16.  
  17. <!DOCTYPE html>
  18. <head>
  19. <title>Form submission</title>
  20. </head>
  21. <body>
  22.  
  23. <form action="" method="post">
  24. First Name: <input type="text" name="first_name"><br>
  25. Last Name: <input type="text" name="last_name"><br>
  26. Email: <input type="text" name="email"><br>
  27. Message:<br><textarea rows="5" name="message" cols="30"></textarea><br>
  28. <input type="submit" name="submit" value="Submit">
  29. </form>
  30.  
  31. </body>
  32. </html>
Add Comment
Please, Sign In to add comment