Advertisement
Guest User

Untitled

a guest
Jan 24th, 2017
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.32 KB | None | 0 0
  1. <!DOCTYPE html>
  2.   <html>
  3.   <head>
  4.     <title>Test page</title>
  5.   </head>
  6.   <body>
  7.   <?php
  8.     // Checking if form has been posted
  9.     if ($_POST) {
  10.       // Email Address destination
  11.       $to = "djr32@kent.ac.uk";
  12.       // Email subject
  13.       $subject = "Subject: ".$_POST["drop_menu"];
  14.       // Email body
  15.       $name = "Name: ".$_POST["name"];
  16.       $email = "Email Address: ".$_POST["email"];
  17.       $commentbox = "Message: ".$_POST["commentbox"];
  18.       // Mailing
  19.       if (mail($to, $subject, $name, $commentbox, $email)) {
  20.         // Successfully sent
  21.         header("Location: redirect.html");
  22.       } else {
  23.         // Failed
  24.         echo('<h1 class="msg error">Email delivery failed…</h1>');
  25.       }
  26.     }
  27.   ?>
  28.     <!-- Form -->
  29.     <form method="POST">
  30.       <!--  Dropdown Menu-->
  31.       Please select an option: <select name="drop_menu">
  32.         <option value="dog">Dog</option>
  33.         <option value="cat">Cat</option>
  34.         <option value="duck">Duck</option>
  35.       </select><br>
  36.     Name: <input type="text" name="name" />
  37.         <br>
  38.     Email Address: <input type="text" name="email" /><br>
  39.     Enter Message:  <textarea id="commentbox" class="text" cols="86" rows ="20" name="commentbox" ></textarea>
  40.       <!--  Send button-->
  41.       <input type="submit" value="Send Form" />
  42.     </form>
  43.   </body>
  44.   </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement