Advertisement
Guest User

Untitled

a guest
Jul 19th, 2018
297
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.24 KB | None | 0 0
  1. <?php
  2. $title = "Contact";
  3. $page = "contact";
  4.  
  5. require_once('_inc/base.php');
  6. require_once('_inc/header.php');
  7.  
  8.  
  9. $emailSent = false;
  10.  
  11. if (isset($_POST['submit'])) {
  12.    
  13.    
  14.     $name = $_POST['name'];
  15.     $mailfrom = $_POST['mail'];
  16.     $message = $_POST['message'];
  17.  
  18.     $mailTo = "sample.email@thissite.com";
  19.     $headers = "From: ".$mailfrom;
  20.     $txt = "You have received an e-mail from ".$name.".\n\n".$message;
  21.  
  22.     if (@mail($mailTo, $txt, $message, $headers)){
  23.         $success = "Message successfully sent";
  24.        
  25.         $emailSent = true;
  26.     }else{
  27.         $success = "Message Sending Failed, try again";
  28.     }
  29.  
  30. }
  31.  
  32. ?>
  33.  
  34.  
  35.  
  36. <div class="col-md-12">
  37.  
  38. <?php
  39. if (isset($success)){ echo "<div>" . $success . "</div>";}
  40. ?>
  41. <?php if ($emailSent == true) { ?>
  42. <h2>Thank you <?php echo $name ?>
  43. <?php } else { ?>
  44.     <h1>Contact</h1>
  45.    
  46.     <h2>Contact Form</h2>
  47.     <form method="post" name="contactform" action="contact.php">
  48.         Name: <input type="text" name="name"><br>
  49.         E-mail: <input type="text" name="mail"><br>
  50.         Comment: <textarea rows="4" cols="50" name="message"></textarea>
  51.         <input type="submit" name="submit">
  52.     </form>
  53.     <?php } ?>
  54. </div>
  55.  
  56.  
  57.  
  58. <?php require_once('_inc/footer.php'); ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement