Advertisement
Guest User

Untitled

a guest
Sep 20th, 2017
605
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.04 KB | None | 0 0
  1. <?php
  2.  
  3. if(isset($_POST['contact_name']) && isset($_POST['contact_email']) && isset($_POST['contact_text'])) {
  4.     $contact_name = $_POST['contact_name'];
  5.     $contact_email = $_POST['contact_email'];
  6.     $contact_text = $_POST['contact_text'];
  7.    
  8.     if(!empty($contact_name) && !empty($contact_email) && !empty($contact_text)) {
  9.         $to = 'zeiterius1997@yahoo.com';
  10.         $subject = 'Contact form submitted.';
  11.         $body = $contact_name."\n".$contact_text;
  12.         $headers = 'From: '.$contact_email;
  13.        
  14.         if (mail($to, $subject, $body, $headers)) {
  15.             echo 'Thanks for contacting us. We\'ll be in touch soon.';
  16.         } else {
  17.             echo 'Sorry, an error occurred. Please try again later.';
  18.            
  19.            
  20.         }
  21.     } else {
  22.         echo 'All fields are required.';
  23.     }
  24. }
  25.  
  26. ?>
  27.  
  28. <form action="index.php" method="POST">
  29.         Name:<br><input type="text" name="contact_name"><br><br>
  30.         Email address:<br><input type="text" name="contact_email"><br><br>
  31.         Message:<br>
  32.         <textarea name="contact_text" rows="6" cols="30"></textarea><br><br>
  33.         <input type="submit" value="Send">
  34.        
  35.        
  36. </form>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement