Advertisement
Guest User

yas's error

a guest
Mar 23rd, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.25 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>AmeriCamp - Home</title>
  5.  
  6. <meta charset="UTF-8">
  7. <meta name="viewport" content="width=device-width">
  8. <meta name="keywords" content="AmeriCamp, camp in America, America camping">
  9. <meta name="description" content="AmeriCamp was founded on a dream to offer the highest salaries and lowest prices for people around the world who wanted to work at what people would refer to as “Camp America”.">
  10. <link rel="stylesheet" type="text/css" href="styles/americamp-styles.css">
  11. </head>
  12.  
  13. <body>
  14. <table>
  15. <tr>
  16. <th>
  17. <a href="index.html">
  18. <img src="images/americamp.jpg" alt="logo" width="340" height="200">
  19. </a>
  20. </th>
  21. <!--Links to each page-->
  22. <th>
  23. <a href="index.html">Home</a>
  24. <a href="about.html">About</a>
  25. <a href="comment.php">Comment</a>
  26. <a href="gallery.html">Gallery</a>
  27. <a href="contact.html">Contact</a>
  28. </th>
  29. </tr>
  30. <tr>
  31. <td>
  32. <a href="https://www.americamp.co.uk/about/americamp-bloggers/" target="_blank">
  33. <img src="images/Check-out-our-AmeriCamp-Bloggers.jpg" width="340" height="400" alt="Check-out-our-AmeriCamp-Bloggers">
  34. </a>
  35. <h2>
  36. <b>Follow Us</b>
  37. <br>
  38. <br>
  39. <a href="https://www.facebook.com/AmeriCamp">
  40. <img src="images/fblogo.png" alt="Fb-logo" width="140" height="150">
  41. </a>
  42. <br>
  43. <br>
  44. <a href="https://www.instagram.com/americamp/">
  45. <img src="images/instalogo.png" alt="insta-logo">
  46. </a>
  47. <br>
  48. <br>
  49. <a href="https://twitter.com/americamp">
  50. <img src="images/twitterlogo.png" alt="twitter-logo">
  51. </a>
  52. <br>
  53. </h2>
  54. </td>
  55. <td class="boxes">
  56. <h3>Comment</h3>
  57. <b>AmeriCamp Mailing List</b>
  58. <h3>
  59. To think that this could be the start of a wonderful adventure! #FreeBiscuits x
  60. the world to do Summer Camp in America 2017 and has won many awards including Best Summer Camp America 2016 Organisation.
  61. </h3>
  62.  
  63. <?php
  64. //Error section
  65. $nameE = $emailE = $genderE = "";
  66. //Variables
  67. $name = $email = $gender = $comment = "";
  68.  
  69. //Name Section
  70. if ($_SERVER["REQUEST_METHOD"] == "POST") {
  71. {
  72. if(empty($_POST["name"])) {
  73. $nameE = "Name is required";
  74. }
  75. else
  76. {
  77. //checks if the name only contain letters and space.
  78. $name = test_input($_POST["name"]);
  79.  
  80. if(!preg_match("[a-zA-Z]*$/^", $name)){
  81. $nameE = "Only letters and space required.";
  82. }
  83. //Email section
  84. if (empty($_POST["email"]))
  85. {
  86. $emailE = "Email is required.";
  87. }
  88. else
  89. {
  90. $email = test_input($_POST["email"]);
  91. //checks if email address is entered right.
  92. if(!filter_var($email, FILTER_VALIDATE_EMAIL))
  93. $emailE = "Invalid";
  94. }
  95.  
  96. //Comment section
  97. if(!empty($_POST["comment"]))
  98. {
  99. $comment = test_input($_POST["comment"]);
  100. }
  101.  
  102. //Gender section
  103. if(empty($_POST["gender"]))
  104. {
  105. $genderE = "Required";
  106. }
  107. else
  108. {
  109. $gender = test_input($_POST["gender"]);
  110. }
  111. }
  112.  
  113. function test_input($data)
  114. {
  115. $data = trim($data);
  116. $data = stripslashes($data);
  117. $data = htmlspecialchars($data);
  118. return $data;
  119. }
  120.  
  121. ?>
  122. <form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">
  123. Name:
  124. <input type="text" name="name">
  125. <span class="erorr">* <?php echo $nameE;?></span>
  126. <br><br>
  127.  
  128. E-mail:
  129. <input type="text" name="email">
  130. <span class="error">* <?php echo $emailE;?></span>
  131. <br><br>
  132.  
  133. Comment: <textarea name="comment" rows="5" cols="40"></textarea>
  134. <br><br>
  135.  
  136. Gender:
  137. <input type="radio" name="gender" <?php if (isset($gender) && $gender=="female") echo "checked";?> value="female">Female
  138. <input type="radio" name="gender" <?php if (isset($gender) && $gender=="male") echo "checked";?> value="male">Male
  139. <span class="error">* <?php echo $genderE;?></span>
  140. <br><br>
  141. <input type="submit" name="submit" value="Submit">
  142. </form>
  143.  
  144. <?php
  145. echo $name;
  146. echo "<br>";
  147. echo $email;
  148. echo "<br>";
  149. echo $comment;
  150. echo "<br>";
  151. echo $gender;
  152. ?>
  153. </td>
  154. </tr>
  155. </table>
  156.  
  157. </body>
  158. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement