大家好,我已经连续工作了 12 个小时,我似乎无法找到解决办法。我正在尝试将用户输入与数据库结果进行比较,例如$username == $result
echo "用户名已被使用,但问题是它通过 2 个语句而没有中断,如果我设置中断以退出循环,它总是检查$email == $result2
尽管不要在该字段中输入任何电子邮件。
if (isset($_POST['username']) or isset($_POST['email'])) {
$extract = mysql_query("
SELECT
`username`, `email`
FROM `users`
WHERE `username`='$username' OR `email`='$email'
");
$resultq = mysql_num_rows($extract);
while ($row = mysql_fetch_array($extract)) {
$result = $row['username'];
$result2 = $row['email'];
echo " " . $result;
echo " " . $result2;
if ($username == $result) {
echo " Username is already Taken!";
// break; //whenever i put break, it always gives me the else if statement echo, despite not entering any email in the field
} //$pass = $_POST['pass'];
else if ($email == $result2) {
echo "Email Address is already used!";
// break;
} else {
}
}
}