为什么它没有在php中检测大写字母

时间:2016-08-26 20:45:37

标签: php html mysql css3

这是其他人的代码,似乎适合所有人在线,但我。 它似乎没有检测到大写字母,即使我有专门的代码。

有人可以在我的代码中发现错误:

<?php

if($_POST['submit']){


    if(!$_POST['email']) $error.="<br />Please enter your email";
        else if (!filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) $error.="<br />Please enter a valid mail";

    if(!$_POST['password']) $error.="<br />Please enter your password";
    else {

            if(strlen($_POST['password'])<8) $error.="<br />Please enter a password with atleast 8 characters";
            if(!preg_match('/[A-Z]/', $_post['password'])) $error.="<br />Please enter atleast one capital letter";
        }

        if($error) echo "There were error(s) in your details:".$error;

    }   

?>




<form method="post">

        <input type="email" name="email" id="email" />
        <input type="password" name="password" />
        <input type="submit" name="submit" value="signup" />

</form>

以下是指向它的链接:

http://hassannasir.co.uk/mysql/

1 个答案:

答案 0 :(得分:5)

PHP变量区分大小写。 $_POST$_post是两个完全不同的变量。

如果启用了error_reporting和display_errors,那么在使用未定义变量时,您已经被告知$ _post是未定义的和未定义的索引。