本文介绍了数据库不检查用户名是否空闲的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
好的,我还有一个问题,现在代码已经修复:
Okay, I have another problem, the code is fixed now:
{
//Check if user already exists
$un_check = mysql_query("SELECT Username FROM users WHERE Username = '$un'");
if(mysql_num_rows($un_check) >0) {
echo "Username already exists";
}
else{
// Username Free
}
但是数据库仍然允许用户名相同。
另外,即使它说用户名已存在,我仍然创建帐户?
But the database still allows usernames to be the same.Also, even though it says "username already exists" I still creates the account anyway?
任何想法?
推荐答案
试试这个
try this
$un_check = mysql_query("SELECT Username FROM users WHERE Username = 'POSTVALUE'");
if(mysql_num_rows($un_check) >0) {
echo "Username is taken";
}
else{
// Username Free
}
这篇关于数据库不检查用户名是否空闲的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!