This is my current code. It correctly connects to the DB, but even if I enter an e-mail that does exist in the xf_users table, it always echos “Account not found”. All I need it to do is fetch the userrname associated with the e-mail the user submits in a form and put it in $username for use later:
$stmt = $db_site->prepare('SELECT * FROM xf_user WHERE email = ?');
$s1tmt->bind_param('s', $email);
$stmt->execute();
$stmt->store_result();
if($stmt->num_rows>0) {
$stmt->bind_result($username);
$stmt->fetch();
echo $username;
exit();
} else {
echo "Account not found!";
exit();
}
Any help would be most appreciated! I bet I need to declare $username. But I’m just not sure how to fix it…