Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function checkPassword($pwd) {
- $errors = array();
- $errors['status'] = 0;
- if (strlen($pwd) < 8) {
- $errors['status'] = 1;
- $errors['message'] = '{"Status":"Failed","error_message":"Password Must be 8 characters long."}';
- }
- if (!preg_match("#[0-9]+#", $pwd)) {
- $errors['status'] = 1;
- $errors['message'] = '{"Status":"Failed","error_message":"Password Must include atleast one number!"}';
- }
- if (!preg_match("#[a-zA-Z]+#", $pwd)) {
- $errors['status'] = 1;
- $errors['message'] = '{"Status":"Failed","error_message":"Password Must include atleast one letter!"}';
- }
- return $errors;
- }
- function checkUsername($username){
- $user_array = array();
- $user_array['pass_status'] = 0;
- if(strlen($username) < 6 ){
- $user_array['pass_status'] = 1;
- $user_array['pass_message'] = '{"Status":"Failed","error_message":"Minimum Password length must be 6 characters or greater."}';
- }
- if(strlen($username) > 20){
- $user_array['pass_status'] = 1;
- $user_array['pass_message'] = '{"Status":"Failed","error_message":"Password length must not exceed 20 characters."}';
- }
- if ( preg_match('/\s/',$username) ){
- $user_array['pass_status'] = 1;
- $user_array['pass_message'] = '{"Status":"Failed","error_message":"Space is not allowed in username."}';
- }
- if (preg_match('/[\'^£$%&*()}{@#~?><>,|=+¬-]/', $username)){
- $user_array['pass_status'] = 1;
- $user_array['pass_message'] = '{"Status":"Failed","error_message":"Special Characters are not allowed in username"}';
- }
- return $user_array;
- }
- $password = "12am3456";
- $u = "sahilaa12";
- $user = checkUsername($u);
- $arr = checkPassword($password);
- print_r($user);
- ?>
Add Comment
Please, Sign In to add comment