PHP HTML Password
From w3cyberlearnings
Contents |
PHP works with HTML Input for password
HTML input tag with the type password is password input.
Syntax password
<input type="password" name="password" size="33" maxlength="33" />
Example 1
- strlen() function check the length of the string.
- In this example, we only allow when the passwords are both matched, and the length of the password have to be at least 8 characters length and not more than 18 characters length.
<?php if ($_POST) { $pass1 = $_POST['pass1']; $pass2 = $_POST['pass2']; if ($pass1 == $pass2 && !empty($pass2) && strlen($pass1) >= 8 && strlen($pass1) <= 18) { $new_password = md5($pass1); echo $new_password; } else { echo 'error'; } } ?> <html> <head> <title>Password</title> </head> <body> <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <table border="0"> <tr> <td>Password:</td> <td> <input type="password" name="pass1" size="20" maxlength="20" autocomplete="off" /> </td> </tr> <tr> <td valign="top">Confirm:</td> <td> <input type="password" name="pass2" size="20" maxlength="20" autocomplete="off" /> </td> </tr> <tr> <td colspan="2"> <input type="submit" name="Submit" value="Submit" /> </td> </tr> </table> </form> </body> </html>
Output
Related Links
- HTML Hidden Field
- HiddenField Multiple Pages
- HTML Password