Advertisement
UrQuan

Hello World 12.5.

May 12th, 2015
450
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.33 KB | None | 0 0
  1. <?php
  2.  
  3. /* 
  4.  *
  5. HTML DIO
  6. <html>
  7. <title>Testna stranica s formom</title>
  8. <body>
  9.     <form action="test.php" method="post">
  10.     <table>
  11.     <tr><td>Login Name:</td><td><input type="text" name="username"></td></tr>
  12.     <tr><td>Password: </td><td><input type="password" name="password"></td></tr>
  13.     <tr><td>First Name: </td><td><input type="text" name="firstName"></td></tr>
  14.     <tr><td>Last Name: </td><td><input type="text" name="lastName"></td></tr>
  15.     <tr><td>E-mail: </td><td><input type="email" name="email"></td></tr>
  16.     <tr><td><input type="submit"></td></tr>
  17.     </table>
  18.     </form>
  19. </body>
  20. </html>
  21.  */
  22.  
  23.  
  24. function passwordValidate($pw){
  25.    
  26. }
  27.  
  28. function howLong($arg, $argName, $len) {
  29.     if (empty($arg)){
  30.         echo("You have not entered your " . $argName);
  31.         exit();
  32.     }
  33.     if (strlen($arg)<$len){
  34.         echo($argName . " " . $arg . " not long enough. <br>
  35.                         Make it longer than " . $len . " symbols.");
  36.         exit();
  37.     }
  38. }
  39.  
  40. function validate($args) {
  41.     foreach($args as $key => $element) {
  42.         switch ($key) {
  43.             case "username":
  44.                 howLong($element, $key, 4);
  45.                 break;
  46.             case "password":
  47.                 howLong($element, $key, 6);
  48.                 break;
  49.             case "firstName":
  50.             case "lastName":
  51.                 howLong($element, $key, 1);
  52.                 break;
  53.             case "email":
  54.                 howLong($element, $key, 5);
  55.                 break;
  56.         }
  57.     }
  58. }
  59.  
  60.  
  61. validate($_REQUEST);
  62. echo "Sve je u redu";
  63.  
  64. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement