我希望 PHP 确保用户名尚未使用,并检查该字段是否为空。对不起,当谈到 php 时,我是一个大菜鸟。这是我的代码:
// Check for an Username:
$dup = mysql_query("SELECT user_username FROM users WHERE user_username='".$_POST['user_username']."'");
if(mysql_num_rows($dup) >0){
$errors[] = 'Username already used.';
}
else{
$un = mysqli_real_escape_string($dbc, trim($_POST['user_username']));
echo '<b>Congrats, You are now Registered.</b>';
}
else {
$errors[] = 'You forgot to enter your Username.';
}