I've searched for the answer to this, and from what I understand, I am missing a { or } somewhere. I keep reviewing my code, however, and I don't see that I have a curly bracket issue. What's going on? What I am trying to do is to get two different types of users accounts (admin, not admin).
<?php
include "header.html";
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
include('include/db-connect.php');
$email = $_POST['email'];
$pass = $_POST['pass'];
try {
if (empty($email) ||
empty($pass))
throw new Exception('Enter all
fields.');
// we're good to go
// SELECT from db
$query = "SELECT * FROM users
WHERE email_address = '$email'";
$result = $con->query($query);
if (!$result)
throw new Exception("Login failed. Please try again.");
$row = $result->fetch_assoc();
$user_id = $row['user_id'];
$hash = $row['user_password'];
$email = $row['email_address'];
$first_name = $row['first_name'];
$user_is_admin = $row['user_is_admin'];
// check password
if (password_verify($pass, $hash)) {
session_start();
$_SESSION['email'] = $email;
$_SESSION['user_id'] = $user_id;
$_SESSION['first_name'] = $first_name;
$_SESSION['user_is_admin'] = $user_is_admin;
if($user_is_admin == TRUE){
echo "yes";
//header("location: admin-user-test.php"); // if user auth is 1, send to admin
}
else if($user_is_admin == FALSE){
echo "no";
//header("location: user-homepage-test.php"); // if user auth is 0, send to admin
}
else {
throw new Exception("Login failed here also. Please try again.");
}
}
catch (Exception $ex) {
echo '<div class="error">' . $ex->getMessage() . '</div>';
}
}
?>