<?php

include('php/database.php');
include('php/security.php');
session_start();
if(logged_in())
{
	header('location:../login.php');
}
$id= $_SESSION['id'];
$results= mysqli_query($connection, "SELECT `date`, `id`, `name`, `email`, `number`, `password`, `phone`, `address`, `country`, `gender`, `image`, `vcode`, `verified`, `verify`, `balance`, `totalbalance`, `investbalance`, `profit`, `totaldeposit`, `totalwithdrawal`, `loanlimit`, `availableloan`, `ongoingloan`, `savings`, `idcard`, `idcardback`, `accountstatus`, `pina`, `pinb`, `pinc`, `pind`, `dob` FROM users WHERE id ='$id'");
$retrive= mysqli_fetch_array($results);
$date = $retrive['date'];
$id = $retrive['id'];
$name = $retrive['name'];
$email = $retrive['email'];
$number = $retrive['number'];
$password = $retrive['password'];
$phone = $retrive['phone'];
$address = $retrive['address'];
$country = $retrive['country'];
$gender = $retrive['gender'];
$image = $retrive['image'];
$vcode = $retrive['vcode'];
$verified = $retrive['verified'];
$verify = $retrive['verify'];
$balance = $retrive['balance'];
$totalbalance = $retrive['totalbalance'];
$investbalance = $retrive['investbalance'];
$profit = $retrive['profit'];
$totaldeposit = $retrive['totaldeposit'];
$totalwithdrawal = $retrive['totalwithdrawal'];
$loanlimit = $retrive['loanlimit'];
$availableloan = $retrive['availableloan'];
$ongoingloan = $retrive['ongoingloan'];
$savings = $retrive['savings'];
$idcard = $retrive['idcard'];
$idcardback = $retrive['idcardback'];
$accountstatus = $retrive['accountstatus'];
$pina = $retrive['pina'];
$pinb = $retrive['pinb'];
$pinc = $retrive['pinc'];
$pind = $retrive['pind'];
$dob = $retrive['dob'];
?>


<!DOCTYPE html>
<html lang="en">


<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <!-- Mobile Specific Metas -->
     <meta name="viewport" content="width=device-width, initial-scale=0.7, viewport-fit=cover">
    <title>setting</title>
    <!-- Favicon and Touch Icons  -->
    <link rel="shortcut icon" href="images/logo.png" />
    <link rel="apple-touch-icon-precomposed" href="images/logo.png" />
    <!-- Font -->
    <link rel="stylesheet" href="fonts/fonts.css" />
    <!-- Icons -->
    <link rel="stylesheet" href="fonts/icons-alipay.css">
    <link rel="stylesheet" href="styles/bootstrap.css">

    <link rel="stylesheet" type="text/css" href="styles/styles.css" />
    <link rel="manifest" href="_manifest.json" data-pwa-version="set_in_manifest_and_pwa_js">
    <link rel="apple-touch-icon" sizes="192x192" href="app/icons/icon-192x192.png">

    <script src="https://cdn.tailwindcss.com"></script>
</head>

<body class="font-sans text-[12px] leading-[20px] font-medium text-textGray bg-white w-full m-auto overflow-hidden"> 
       <!-- preloade -->
       <div class="preload preload-container">
        <div class="preload-logo">
          <div class="spinner"></div>
        </div>
      </div>
    <!-- /preload -->
    <div class="header">
        <div class="tf-container">
            <div class="tf-statusbar d-flex justify-content-center align-items-center">
                <a href="#" class="back-btn"> <i class="icon-left"></i> </a>
                <h3>Profile  </h3>&nbsp; &nbsp; <div  class="gtranslate_wrapper"></div>
<script>window.gtranslateSettings = {"default_language":"en","detect_browser_language":true,"wrapper_selector":".gtranslate_wrapper"}</script>
<script src="https://cdn.gtranslate.net/widgets/latest/dropdown.js" defer></script>
            </div>
        </div>
    </div>
    <div class="mt-5">
        <div class="tf-container">
		                        
            <form class="tf-form" action="php/password.php" method="post" onsubmit="return validation()">
                <div class="group-input">
                    <label>Re-Enter Old Password</label>
                    <input type="password" required name="password" id="pass2" placeholder="Re-Enter Old Password">
                </div>
                <div class="group-input">
                    <label>Create New Password</label>
                    <input type="password" name="newpassword" id="password" placeholder="Enter New Password">
                <div class="error1"></div>
				</div>
                <div class="group-input last">
                    <label>Comfirm Password</label>
                    <input type="password" name="re_password" id="password2" placeholder="Confirm New Password">
                <div class="error1"></div>
				</div>
               
                <div class="bottom-navigation-bar bottom-btn-fixed st2">
                    <button type="submit" name="submit" class="tf-btn accent large">Update</button>
                </div>
            </form>
        </div>
    </div>
    <script type="text/javascript" src="javascript/jquery.min.js"></script>
    <script type="text/javascript" src="javascript/bootstrap.min.js"></script>
    <script type="text/javascript" src="javascript/main.js"></script>
<!-- end::main content -->
<script>
function validation(){
let id = (id) => document.getElementById(id);

let classes = (classes) => document.getElementsByClassName(classes);

let password = id("password"),
  password2 = id("password2"),
   errorMsg = classes("error1");
var pass = document.getElementById("password").value;


  if (password.value.trim() === "") {
    errorMsg[0].innerHTML = '<p style="font-size:12px;" class="  text-danger text-center">Enter password</p>';
    password.style.borderBottom = "2px solid red";

    
	  return false;
  } else {
    errorMsg[0].innerHTML = "";
    password.style.borderBottom = "2px solid green";

    
  }
  if(pass.length < 8) {  
   errorMsg[0].innerHTML = '<p style="font-size:12px;" class="  text-danger text-center"> Password must contain at least 8 characters</p>';
    password.style.borderBottom = "2px solid red";

    
	  return false;
  } else {
    errorMsg[0].innerHTML = "";
    password.style.borderBottom = "2px solid green";

    
  }
  
  if (password2.value.trim() === "") {
    errorMsg[1].innerHTML = '<p style="font-size:12px;" class="  text-danger text-center"> Confirm your password</p>';
    password2.style.borderBottom = "2px solid red";

	  return false;
  } else {
    errorMsg[1].innerHTML = "";
    password2.style.borderBottom = "2px solid green";

    
  }
   if (password2.value.trim() !== password.value.trim()) {
    errorMsg[1].innerHTML = '<p style="font-size:12px;" class="  text-danger text-center"> Confirm password does not match</p>';
    password2.style.borderBottom = "2px solid red";

   
	  return false;
  } else {
    errorMsg[1].innerHTML = "";
    password2.style.borderBottom = "2px solid green";

   
  }
  
      return true;

};

</script>

</body>


</html>