Advertisement
cjantona0630

Untitled

Nov 14th, 2018
2,581
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <html>
  2. <head>
  3. </head>
  4. <body>
  5.  
  6.  
  7. <?php
  8.  
  9.  
  10. $name = $email = $comment = $website = "";
  11.  
  12. if ($_SERVER["REQUEST_METHOD"] == "POST") {
  13.   $name = test_input($_POST["name"]);
  14.   $email = test_input($_POST["email"]);
  15.   $website = test_input($_POST["website"]);
  16.   $comment = test_input($_POST["comment"]);
  17.   $gender = test_input($_POST["gender"]);
  18. }
  19.  
  20. function test_input($data) {
  21.   $data = trim($data);
  22.   $data = stripslashes($data);
  23.   $data = htmlspecialchars($data);
  24.   return $data;
  25.  
  26. ?>
  27.  
  28. <form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">  
  29.   Name: <input type="text" name="name">
  30.   <br><br>
  31.   E-mail: <input type="text" name="email">
  32.   <br><br>
  33.   Website: <input type="text" name="website">
  34.   <br><br>
  35.   Comment: <textarea name="comment" rows="5" cols="40"></textarea>
  36.   <br><br>
  37.   Gender:
  38.   <input type="radio" name="gender" value="female">Female
  39.   <input type="radio" name="gender" value="male">Male
  40.   <input type="radio" name="gender" value="other">Other
  41.   <br><br>
  42.   <input type="submit" name="submit" value="Submit">  
  43. </form>
  44.  
  45. <?php
  46. echo "<h2>Your Input:</h2>";
  47. echo $name;
  48. echo "<br>";
  49. echo $email;
  50. echo "<br>";
  51. echo $website;
  52. echo "<br>";
  53. echo $comment;
  54. echo "<br>";
  55. echo $gender;
  56. ?>
  57.  
  58. </body>
  59. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement