问题
$username = mysqli_real_escape_string($_POST['username']);
$result = mysqli_query($connect, "SELECT * FROM account WHERE username='".$username."' AND activate='0'");
while($row = mysqli_fetch_assoc($result)) {
echo 'Account not activated.';
}
I'm new to MYSQLi and I need help on how do I show an error if the user enter a wrong username and its not activated. So far I got the code above.
回答1:
try this
$username = mysqli_real_escape_string($_POST['username']);
$result = mysqli_query($connect, "SELECT * FROM account WHERE username='".$username."' AND activate='0'");
if ($result->num_rows) {
echo "you are activated !!";
}
else
{
// do what u like here if not activated
}
来源:https://stackoverflow.com/questions/15461765/check-if-username-exist-activated-in-database-using-mysqli