<?php
$checkemail = $conn->prepare("SELECT * FROM loginInfo WHERE username = ? LIMIT 1");
$checkemail->bind_param('s', $un);
$checkemail->execute(); // Execute the prepared query.
$checkemail->store_result();
if ($checkemail->num_rows == 1) {
echo 'error';
echo '<script type="text/javascript">
alert("Error. User already exists.");</script>';
}else {
// insert into table
}
不确定为什么这不起作用它允许我一遍又一遍地创建用户
修改:再次尝试后,它不会将包含相同电子邮件的任何记录插入数据库,但弹出警报未显示