Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $title = "Contact";
- $page = "contact";
- require_once('_inc/base.php');
- require_once('_inc/header.php');
- $emailSent = false;
- if (isset($_POST['submit'])) {
- $name = $_POST['name'];
- $mailfrom = $_POST['mail'];
- $message = $_POST['message'];
- $mailTo = "sample.email@thissite.com";
- $headers = "From: ".$mailfrom;
- $txt = "You have received an e-mail from ".$name.".\n\n".$message;
- if (@mail($mailTo, $txt, $message, $headers)){
- $success = "Message successfully sent";
- $emailSent = true;
- }else{
- $success = "Message Sending Failed, try again";
- }
- }
- ?>
- <div class="col-md-12">
- <?php
- if (isset($success)){ echo "<div>" . $success . "</div>";}
- ?>
- <?php if ($emailSent == true) { ?>
- <h2>Thank you <?php echo $name ?>
- <?php } else { ?>
- <h1>Contact</h1>
- <h2>Contact Form</h2>
- <form method="post" name="contactform" action="contact.php">
- Name: <input type="text" name="name"><br>
- E-mail: <input type="text" name="mail"><br>
- Comment: <textarea rows="4" cols="50" name="message"></textarea>
- <input type="submit" name="submit">
- </form>
- <?php } ?>
- </div>
- <?php require_once('_inc/footer.php'); ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement