Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // Declare some stuff.
- $username = "";
- $password = "";
- // This is not required, but is encouraged to declare all variables.
- $errors = array();
- // Username stuff.
- if(strlen($username) == 0)
- {
- $errors[] = "Where is your username!?";
- }
- elseif(strlen($username) < 2 || strlen($username) > 32)
- {
- $errors[] = "Yur username doesn't meet the requirements! It must not fall below 2 and must not exceed 32 characters.";
- }
- // Password stuff.
- // The second check is pointless, however, it's just an example of what you can do.
- if(strlen($password) <= 0)
- {
- $errors[] = "Where is duh password!?";
- }
- elseif(hash("sha512", $password) !== hash("sha512", $password))
- {
- $errors[] = "Why don't duh passwords match!?";
- }
- // Count the errors, if their is >= 1, list them here.
- if(count($errors) >= 1)
- {
- echo "You have the following problems..";
- echo "<ul>";
- foreach($errors as $error)
- {
- echo "<li>" . $error . "</li>";
- }
- echo "</ul>";
- }
- else
- {
- echo "Login has been accepted.";
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement