Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- *
- HTML DIO
- <html>
- <title>Testna stranica s formom</title>
- <body>
- <form action="test.php" method="post">
- <table>
- <tr><td>Login Name:</td><td><input type="text" name="username"></td></tr>
- <tr><td>Password: </td><td><input type="password" name="password"></td></tr>
- <tr><td>First Name: </td><td><input type="text" name="firstName"></td></tr>
- <tr><td>Last Name: </td><td><input type="text" name="lastName"></td></tr>
- <tr><td>E-mail: </td><td><input type="email" name="email"></td></tr>
- <tr><td><input type="submit"></td></tr>
- </table>
- </form>
- </body>
- </html>
- */
- function passwordValidate($pw){
- }
- function howLong($arg, $argName, $len) {
- if (empty($arg)){
- echo("You have not entered your " . $argName);
- exit();
- }
- if (strlen($arg)<$len){
- echo($argName . " " . $arg . " not long enough. <br>
- Make it longer than " . $len . " symbols.");
- exit();
- }
- }
- function validate($args) {
- foreach($args as $key => $element) {
- switch ($key) {
- case "username":
- howLong($element, $key, 4);
- break;
- case "password":
- howLong($element, $key, 6);
- break;
- case "firstName":
- case "lastName":
- howLong($element, $key, 1);
- break;
- case "email":
- howLong($element, $key, 5);
- break;
- }
- }
- }
- validate($_REQUEST);
- echo "Sve je u redu";
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement