Guest User

Untitled

a guest
Mar 14th, 2018
229
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.66 KB | None | 0 0
  1. <h1>Contact us</h1>
  2. <div id='errors'></div>
  3. <form method='post' name="form" >
  4. <table>
  5. <tr>
  6. <td>Email:</td>
  7. <td><input type="text" name="email" placeholder="Email"></td>
  8. </tr><tr>
  9. <td>Support team?:</td>
  10. <td>
  11. <select name="team">
  12. <option value="none">Pick one</option>
  13. <option value="atrix">Atrix676</option>
  14. <option value="joey">Joey</option>
  15. </select>
  16. </td>
  17. </tr><tr>
  18. <td>Category:</td>
  19. <td><select name="cat">
  20. <option value="cat">Category</option>
  21. <option value="donar">Donations</option>
  22. <option value="other">Other</option>
  23. </select></td>
  24. </tr><tr>
  25. <td>Message:</td>
  26. <td><textarea name="msg" cols="50" rows="8"></textarea></td>
  27. </tr></table>
  28. </tr></table>
  29. <input type='submit' name='submit' value='Submit'>
  30. </form>
  31. <?php
  32. $errors = array();
  33. if (isset($_POST['submit'])) {
  34. if (empty($_POST['email']) || empty($_POST['msg'])) {
  35. $errors[] = 'Please fill in all fields ';
  36. } else {
  37. $email = $_POST['email'];
  38. $msg = $_POST['msg'];
  39. $subject = $_POST['cat'];
  40. $headers = "From: ".$_POST['email'];
  41. if ($_POST['team']=='atrix') {
  42. $to = 'markmp3@live.com';
  43. } else if ($_POST['team']=='joey') {
  44. $to = 'phptech@live.com';
  45. } else {
  46. $to = 'markmp3@live.com';
  47. } if (filter_var($_POST['email'], FILTER_VALIDATE_EMAIL) === false) {
  48. $errors[] = 'Please enter a valid email';
  49. } else {
  50. if (mail($to, $subject, $msg, $headers)) {
  51. echo "Your message has been sent to <b>".ucfirst($_POST['team'])."</b>. You will be answered ASAP";
  52. }
  53. else {
  54. echo "Your message has failed to send. Please try again later.";
  55. }
  56. }
  57. }
  58. foreach($errors as $error) {
  59. echo "<font color='red'>$error</font>";
  60. }
  61. }
  62. ?>
Add Comment
Please, Sign In to add comment