<?php
session_start();
require_once '../config.php';
load('middleware', 'user');
if ($_SESSION['user']['level'] == "") {
    header('location:' . base_url('id'));
}
$id = $_GET['id'];
if(!isset($id))
    die('No direct script access allowed!');
$query = mysqli_query($db, "SELECT * FROM users WHERE id = '$id'");
$q = mysqli_fetch_assoc($query);
if (strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') { ?>
<form method="POST">
<div class="form-group mb-3">
        <label>Email Lama</label>
        <input class="form-control" placeholder="Lynch Store" name="email_old" value="<?= $q['email'];?>" readonly>
    </div>
<div class="form-group mb-3">
        <label>Email Baru</label>
        <input class="form-control" placeholder="cs@lynchstore.xyz" name="email_new">
    </div>
<div class="form-group mb-3">
    <label for="password" class="form-label">Konfirmasi Password</label>
    <div class="input-group mb-3">
        <span class="input-group-text" id="password"><i class="fas fa-lock"></i></span>
        <input type="password" class="form-control" placeholder="password" id="password" name="pass">
        <span class="input-group-text"><i class="far fa-eye-slash" id="togglePassword" style="cursor: pointer" onclick="pwEye(this);"></i></span>
    </div>
</div>
    <hr>
    <div class="float-right">
        <button type="button" data-bs-dismiss="modal" aria-label="Close" class="btn btn-block bg-light fw-bold">BACK</button>
        <button type="submit" name="change_email" class="btn btn-block text-white bg-primary fw-bold">KONFIRMASI</button>
    </div>
</form>
<?php } ?>