Advertisement
Guest User

Untitled

a guest
Feb 25th, 2018
487
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.51 KB | None | 0 0
  1. <?php
  2. /* Set e-mail recipient */
  3. $myemail = "your@email.com";
  4.  
  5. /* Check all form inputs using check_input function */
  6. if (isset($_GET["submit"])) {
  7. $name = $_GET['name'];
  8. $email = $_GET['email'];
  9. $message = $_GET['message'];
  10. }
  11. else {
  12. echo $myError;
  13. }
  14. $subject = "Report From OlympiaMC";
  15.  
  16. /* If input is not valid show error message */
  17. if (!preg_match("/([\w\-]+\@[\w\-]+\.[\w\-]+)/", $email))
  18. {
  19. show_error("E-mail address not valid.");
  20. }
  21. if (preg_match( '/[a-zA-Z]/', $cords )) {
  22. show_error("Coordinates not valid.");
  23. }
  24. /* Let's prepare the message for the e-mail */
  25. $message = "Hello,
  26. This is a report from the OlympiaMC Bootstrap Template. Below is the information...
  27.  
  28. Name: $name
  29. E-mail: $email
  30.  
  31. In-Game Coordinates: $cords
  32. Message: $message
  33.  
  34. End of message
  35. ";
  36.  
  37. /* Send the message using mail() function */
  38. mail($myemail, $subject, $message);
  39.  
  40. /* Redirect visitor to the thank you page */
  41. echo "<script>
  42. window.location.href='index.html';
  43. alert('Thanks, your report has been submitted.');
  44. </script>";
  45. exit();
  46.  
  47. /* Functions we used */
  48. function check_input($data, $problem='')
  49. {
  50. $data = trim($data);
  51. $data = stripslashes($data);
  52. $data = htmlspecialchars($data);
  53. if ($problem && strlen($data) == 0)
  54. {
  55. show_error($problem);
  56. }
  57. return $data;
  58. }
  59.  
  60. function show_error($myError)
  61. {
  62. ?>
  63. <html>
  64. <body>
  65.  
  66. <b>Please correct the following error:</b><br />
  67. <?php echo $myError; ?>
  68.  
  69. </body>
  70. </html>
  71. <?php
  72. exit();
  73. }
  74. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement