Advertisement
cevhyruz

index.php

Aug 19th, 2019
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.58 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3.   <head>
  4.     <title>PHP Form Handling</title>
  5.   </head>
  6.   <body>
  7.     <form action="index.php" method="POST">
  8.       <input type="text" name="username"/>
  9.       <input type="submit" value="Send"/>
  10.     </form>
  11.   </body>
  12. </html>
  13.  
  14. <?php
  15.  
  16. if ($_SERVER['REQUEST_METHOD'] == 'POST') {
  17.   $input = $_POST['username'];
  18.   if (is_numeric($input)) {
  19.     if ($input < 18 || $input > 90) {
  20.       echo 'cannot vote';
  21.     } else {
  22.       echo 'can vote';
  23.     }
  24.   } else if (empty($input)) {
  25.     echo 'empty input';
  26.   } else {
  27.     echo 'invalid input: ', $input;
  28.   }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement