PHP寄存器工作不正常


PHP Register not working correctly

我创建的PHP注册页面出现错误。

<?php
$username = $_POST['username'];
$password = $_POST['password'];
if(isset($_POST['submit'])) {
    if($username < 6 || $password < 6){
        echo 'The username must be longer than 5 characters';   
    }
    else {
    $query = mysql_query("INSERT INTO users (username,password) VALUES ('".$username."',MD5('".$password."'))");
    }
}
?>
<form method="post">
Username: <input type="text" name="username" maxlength="20" />
<BR>Password: <input type="password" name="password" maxlength="32" />
<BR><input type="submit" name="submit" />
</form>

每当我点击提交时,即使用户名和密码超过5个字符,它也会不断显示错误消息。

页面链接到数据库,但这只是我遇到问题的片段。

感谢

-Nicholas

您需要检查用户名和密码的长度是否为<6而不是$username

strlen($username) <6 OR strlen($password) <6
if(strlen($username) < 6 || strlen($password) < 6){
        echo 'The username must be longer than 5 characters';   
}

请检查php strlen($username)中的php字符串函数