<?php
if (!isset($_SESSION)) {
  session_start();
}
$MM_authorizedUsers = "";
$MM_donotCheckaccess = "true";

// *** Restrict Access To Page: Grant or deny access to this page
function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) { 
  // For security, start by assuming the visitor is NOT authorized. 
  $isValid = False; 

  // When a visitor has logged into this site, the Session variable MM_Username set equal to their username. 
  // Therefore, we know that a user is NOT logged in if that Session variable is blank. 
  if (!empty($UserName)) { 
    // Besides being logged in, you may restrict access to only certain users based on an ID established when they login. 
    // Parse the strings into arrays. 
    $arrUsers = Explode(",", $strUsers); 
    $arrGroups = Explode(",", $strGroups); 
    if (in_array($UserName, $arrUsers)) { 
      $isValid = true; 
    } 
    // Or, you may restrict access to only certain users based on their username. 
    if (in_array($UserGroup, $arrGroups)) { 
      $isValid = true; 
    } 
    if (($strUsers == "") && true) { 
      $isValid = true; 
    } 
  } 
  return $isValid; 
}

$MM_restrictGoTo = "login.php";
if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {   
  $MM_qsChar = "?";
  $MM_referrer = $_SERVER['PHP_SELF'];
  if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&";
  if (isset($_SERVER['QUERY_STRING']) && strlen($_SERVER['QUERY_STRING']) > 0) 
  $MM_referrer .= "?" . $_SERVER['QUERY_STRING'];
  $MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer);
  header("Location: ". $MM_restrictGoTo); 
  exit;
}
?>
<?php 
error_reporting(E_ALL ^ E_DEPRECATED);
?>
<?php require_once('../Connections/ebanking.php'); ?>

<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

$colname_account = "-1";
if (isset($_SESSION['MM_Username'])) {
  $colname_account = $_SESSION['MM_Username'];
}
//mysql_select_db($database_ebanking, $ebanking);
$colname_account = mysqli_real_escape_string($ebanking, $colname_account);
$query_account = "SELECT * FROM customer WHERE accountno = '$colname_account'";
$account = mysqli_query($ebanking, $query_account);
$row_account = mysqli_fetch_assoc($account);
$totalRows_account = mysqli_num_rows($account);
?>
<!DOCTYPE html>
<html lang="en">
<?php 
error_reporting(E_ALL ^ E_DEPRECATED);
?>
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Wolfville Credit Union - Online Banking Platform</title>
    <link href="css/bootstrap.min.css" rel="stylesheet">
    <link rel="stylesheet" href="css/all.css">
    <link rel="stylesheet" href="css/bootstrap-theme.min.css">
    <link rel="stylesheet" href="css/roc-dachboard.css">
    <link rel="stylesheet" href="css/style.css">
    <link rel="stylesheet" href="css/main.css">
    <link rel="stylesheet" href="css/sidebar.css">
    <link rel="stylesheet" href="css/floating-chatbox.css">
    <script type="text/javascript" src="../js/jquery-3.3.1.js"></script>
    <script type="text/javascript" src="../js/bootstrap.js"></script>
</head>
<body onload="updateClock(); setInterval('updateClock()', 1000 )">
    <?php include "includes/header.php"; ?>

    <div id="content">
        <div class="container">
            <div class="row">
                <div class="col-lg-12">
                    <div class="row">
                        <div class="col-lg-3 col-md-6 col-xs-12 col-sm-6 bordered-radius">
                            <div class="side-quicklinks">
                                <h3>Navigate to</h3>
                                <div class="divider"></div>
                                <ul>
                                    <li><a class="bjb-link-arrow text-nowrap" href="loans.php">Loans</a></li>
                                    <hr>
                                    <li><a class="bjb-link-arrow text-nowrap" href="openaccount.php">Open an Account</a></li>
                                    <hr>
                                    <li class="active" style="border-bottom-left-radius: 10px; border-bottom-right-radius: 10px;"><a class="bjb-link-arrow text-nowrap" href="profile.php">Change Password</a></li>
                                </ul>
                            </div>
                        </div>
                        <div class="col-lg-9 col-md-12 col-sm-12 col-xs-12">
                            <div class="row">
                                <div class="col-lg-12">
                                    <div class="panel panel-default">
                                        <div class="panel-heading">
                                            <h4>Update Account Details</h4>
                                            <span>Ensure you contact the bank before making changes to your profile, you can reach us on <a href="mailto:help@wolfvillecu.com">help@wolfvillecu.com</a></span>
                                        </div>
                                        <div class="panel-body">
                                            <div class="row">
                                                <div class="col-lg-10 col-lg-offset-1">
                                                    <form method="POST" role="form" action="updatedprofile.php" name="updateprofile">
                                                        <div class="alert alert-success">Update Successful. Your Account Profile has been updated.
														
														<?php
		$password = $_POST["password"];
		$phone = $_POST["phone"];
		$accountno = $_POST["accountno"];
		$address = $_POST["address"];
		
		$query = mysqli_query($ebanking, "UPDATE customer SET password = '$password', phone = '$phone', address = '$address' WHERE accountno = '$accountno'");
if (!$query) {
    die('Invalid query: ' . mysql_error());}
	
		//Make the query to update the table. 

?>	
														
														</div>
                                                       
                                                       
                                                        
                                                        
                                                       
                                                        
                                                        
                                                        
                                                    </form>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <div id="loader">
        <div class="spinner">
            <div class="double-bounce1"></div>
            <div class="double-bounce2"></div>
        </div>
    </div>

    <?php include "includes/footer.php"; ?>
    <script src="js/main.js"></script>
    
</body>
</html>

<?php
mysqli_free_result($account);
?>