Reputation: 462
For my login system, I'm trying to retrieve the user's information from a database based on the email. My code looks like this:
session_start();
require "database.php";
$db = new Database("bills.db");
$email = $_POST['email_address'];
$password = $_POST['user_password'];
$stmt = $db->prepare("SELECT * FROM billgroup WHERE (adminemail = :email)");
$stmt->bindValue(':adminemail', $email, SQLITE3_TEXT);
$users = $stmt->execute();
$user = $users->fetchArray();
However whenever I run this, I cannot log in, and the $user array is always empty. Any help would be so appreciated.
Upvotes: 2
Views: 51
Reputation: 5685
$stmt->bindValue(':adminemail', $email, SQLITE3_TEXT);
Should be
$stmt->bindValue(':email', $email, SQLITE3_TEXT);
To match the defined variable in the query.
Upvotes: 1