<?php
session_start();
ob_start();
if (!isset($_SESSION['hash'])) {
  header("Location: login");
  exit();
} else {
  $hash = $_SESSION['hash'];
}
?>

<?php
require_once("conn.php");
$sql = "SELECT * FROM accounts WHERE id='$hash'";
$result = $dbconfig->query($sql);
if ($result->num_rows == 1) {
  while ($row = $result->fetch_assoc()) {
    define('passportPath', 'passport/');
    $dbid = $row['id'];
    $dbfirst_name = $row['first_name'];
    $dbmiddle_initial = $row['middle_initial'];
    $dblast_name = $row['last_name'];
    $dbaddress = $row['address'];
    $dbzip_code = $row['zip_code'];
    $dbcountry = $row['country'];
    $dbstate = $row['state'];
    $dbemail = $row['email'];
    $dbphone = $row['phone'];
    $dbsex = $row['sex'];
    $dbgov_iss_id_no = $row['gov_iss_id_no'];
    $dbssn_tin = $row['ssn_tin'];
    $dbdob = $row['dob'];
    $dbemail_status = $row['email_status'];
    $dbregistration_date = $row['registration_date'];
    $dbstatus = $row['status'];
    $dbaccount_number = $row['account_number'];
    $dbusername = $row['username'];
    $dbpin = $row['pin'];
    $dbpassword = $row['password'];
    $dbsecurity_question = $row['security_question'];
    $dbsecurity_answer = $row['security_answer'];
    $dbbalance = $row['balance'];
    $dbcurrency = $row['currency'];
    $dbpassport = $row['passport'];
    $dbcard_status = $row['card_status'];
    $dbcard_otp = $row['card_otp'];
    $dbcard_name = $row['card_name'];
    $dbcard_number = $row['card_number'];
    $dbcard_exp = $row['card_exp'];
    $dbcard_type = $row['card_type'];


    if ($dbstatus == 'disable' OR $dbstatus == 'pending') {
      header("Location: logout");
      exit();
    }
  }
} else {
  header("Location: logout");
  exit();
}
?>
