PHP在注册表单上重复使用用户名

时间:2018-04-14 21:27:22

标签: php forms duplicates

试图阻止用户注册重复的帐户,但代码似乎不起作用,不知道我做错了什么,

var_dump count显示“string(1)”0“

        $query1 = "SELECT COUNT(*) FROM users WHERE user_email = :email OR user_name = :username";
        $stmt = $DBH->prepare($query1);
        $stmt->execute(array(':username' => $username,':email' => $email));
        $count = $stmt->fetchColumn();

        // var_dump($count);

        if ($count > 0) {
            $error = "Username or E-Mail in Use. Please try another.";
        }

0 个答案:

没有答案