For user registration, I want to make sure the username and emails aren’t already in use. I have already connected to $mysqli somewhere else in the code.
$usr = $mysqli->real_escape_string($_POST['susername']);
$eml = $mysqli->real_escape_string($_POST['semail']);
$stmt = $mysqli->prepare("SELECT userid FROM users WHERE username=? || email=?");
$stmt->bind_param("is", $usr, $eml);
$stmt->execute();
$stmt->bind_result($count);
$stmt->close();
However, count contains nothing. How can I check if something already exists in the DB?
Change,
To
Then you should fetch the value using
fetch()