每次满足其中一项要求时,如何弹出复选标记?

时间:2018-03-26 23:32:03

标签: php passwords

我坚持每次满足要求时都会弹出复选标记。因此,如果满足所有要求,我只会获得一个带有数字但没有其他数字的复选标记。还有其他方法可以改进我的代码。我的所有残疾人都会弹出,所以我剩下的只是让校验标记起作用。

<?php
$username =(isset($_POST['username']) ? $_POST['username'] : "");
$password = (isset($_POST['password'])? $_POST['password'] : "");
$login= False;

$Formula='/(?=.*\d)/';// Digits
$Formula2='/(?=.*[!@#$%\^&\?])/';//Special Characters
$Formula3='/(?=.[a-z])/';// Lower case letter
$Formula4='/(?=.*[A-Z])/';// Upper case letter
$Formula5='/(?=.{8,16})/'; // Length at least 8-16 characters
$Formula6='/(\S)/';// No white spaces
$Vaild= "<div>&#9989;</div>";
$Invalid ="<div>&#x1f6ab</div>";

if(isset($_POST['Submit'])){
    if(preg_match($Formula,$password)){
        echo"$Vaild.You have a number.";
    }else{
        echo"$Invalid Invalid password must have at least one number.<br/>";
        if(preg_match($Formula2,$password)){
            echo "$Vaild You have a special character";
        }else{
            echo"$Invalid Invalid password you need to have at least one special characters.<br/>";
            if(preg_match($Formula3,$password)){
                Echo"$Vaild You met the lower case letter requirement.";
            }else{
                echo "$Invalid Invalid password you need to have a lower case letter .";
                if(preg_match($Formula4,$password)){
                    echo" $Vaild You have met the upper case letter requirement.";
                }else{
                    echo "$Invalid Invalid password you need to have a upper case letter .";
                    if(preg_match($Formula5,$password)){
                        echo"$Vaild You have met the requirement of having eight to sixteen characters.";
                    }else{
                        echo "$Invalid Invalid password you need to be eight to sixteen characters long.";
                        if(preg_match($Formula6,$password)){
                            echo"$Vaild You have met the requirement of no white spaces.";
                        }else{
                            echo "$Invalid Invalid password you can't have any white spaces in your password.";
                        }
                    }
                }
            }
        }
    }
}
if(!$login){
    ?>
<form name ="loginForm" action="part2.php" method="POST">
Username :<input type="text" name="username"
value="<?php echo $username;?>"/><br/>
Password: <input type ="password" name="password"
value=""/><br/>
<input type="submit" name="Submit"/>
<?php } ?>
</form>

0 个答案:

没有答案