Reputation: 271
I've got two php values called $email and $pass.
email - Name of row in MySQL database password - Name of row in MYSQL database
I'm running a sql query to select from table member where email = $email and password =$pass.
I'm then running mysqli_query to see if a row exists, I'm not getting any results. Surely the echo would echo out the ID of where the info matches.
//Get the connection info.
global $connect;
$sql = "SELECT FROM members WHERE email='$email' AND password='pass'";
//Fetch the row and store the ID of this row.
$row = mysqli_query($connect, $sql);
$id = $row['userID'];
echo $id;
Upvotes: 0
Views: 17914
Reputation: 1757
Besides the fact that this code is massively exposed to SQL injection.. you are querying the data but not fetching the results.
add the fetch command:
$data = mysqli_query($connect, $sql);
$row = mysqli_fetch_assoc($data);
$id = $row['userID'];
Upvotes: 2