<?php
require("header.php")
?>


<div class="content-wrapper">
  <!-- Content Header (Page header) -->
  <section class="content-header">
    <div class="container-fluid">
      <div class="row mb-2">
        <div class="col-sm-6">
          <!-- <h1>Change Password</h1> -->
        </div>
      </div>
    </div><!-- /.container-fluid -->
  </section>

  <!-- Main content -->
  <section class="content">

    <div class="container-fluid">
      <div class="row">
        <div class="col-md-3">

          <!-- Profile Image -->
          <div class="card card-dark card-outline">
            <div class="card-body box-profile">
              <div class="text-center">
                <img src="dist/img/avatar5.png" class="profile-user-img img-fluid img-circle" style="border: 3px solid #343a40;" alt="User profile picture">
              </div>

              <h3 class="profile-username text-center">Admin</h3>

              <!-- <p class="text-muted text-center">Software Engineer</p> -->
              <br>

              <ul class="list-group list-group-unbordered mb-3">
                <?php
                $sql = "select * from v_admin";
                $res = mysqli_query($conn, $sql);
                if ($row = mysqli_fetch_array($res)) {
                ?>
                  <li class="list-group-item">
                    <b>Password</b> <a class="float-right" style="color:red"><?php echo $row['password']; ?></a>
                  </li>
                  <li class="list-group-item">
                    <b>Answer</b> <a class="float-right" style="color:red"><?php echo $row['answer']; ?></a>
                  </li>

                <?php } ?>
              </ul>

              <!-- <a href="#" class="btn btn-primary btn-block"><b>Follow</b></a> -->
            </div>
            <!-- /.card-body -->
          </div>
          <!-- /.card -->

        </div>
        <!-- /.col -->
        <div class="col-md-9">


          <!-- general form elements -->
          <div class="card card-secondary" style="height:95%">
            <div class="card-header" style="background-color: black;">
              <h3 class="card-title">Change Password</h3>
              <ol class="breadcrumb float-sm-right" style="background-color: black;">
                <li class="breadcrumb-item"><a href="#">Home</a></li>
                <li class="breadcrumb-item">Setting</li>
                <li class="breadcrumb-item active">Change Password</li>
              </ol>
            </div>
            <!-- /.card-header -->
            <!-- form start -->
            <div class="card-body">

              <form class="form-horizontal" action="profile_setting_code.php" method="post">
                <?php
                $sql = "select * from v_admin";
                $res = mysqli_query($conn, $sql);
                if ($row = mysqli_fetch_array($res)) {
                ?>
                  <br>
                  <div class="form-group row">
                    <label for="inputName" class="col-sm-3 col-form-label">Change Password :</label>
                    <div class="col-sm-9">
                      <input type="pass" class="form-control" name="password" value="<?php echo $row['password']; ?>" id="oldpassword" placeholder="Enter old Password">
                    </div>
                  </div>

                  <div class="form-group row">
                    <label for="inputName2" class="col-sm-3 col-form-label">Change Answer :</label>
                    <div class="col-sm-9">
                      <input type="text" class="form-control" name="answer" value="<?php echo $row['answer']; ?>" id="inputName2" placeholder="Answer">
                    </div>
                  </div>
                <?php } ?>
                <div class="form-group row">
                  <div class="offset-sm-3 col-sm-9 mb-3">
                    <button type="reset" class="btn btn-dark" style="width: 20%; background:black">Clear </button>&nbsp;
                    <button type="submit" name="change" class="btn btn-dark" style="width:20%; background:black;">Update </button>
                  </div>
                </div>
              </form>
            </div>

          </div>
          <!-- /.card -->

        </div>
        <!-- /.col -->
      </div>
      <!-- /.row -->
    </div>
    <!-- /.container-fluid -->

  </section>

  <!-- /.content -->
</div>
<!-- for searching -->
<script>
  var loadFile = function(event) {
    var image = document.getElementById('output');
    image.src = URL.createObjectURL(event.target.files[0]);
  };
</script>
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
<!-- Sweet Alert  start-->
<?php if (isset($_REQUEST['msg']) && $_REQUEST['msg'] == 1) { ?>
  <script>
    Swal.fire(
      'Good job!',
      'Updated Successfully!!',
      'success'
    ).then(() => {
      window.location.href = "profile_setting.php";
    });
  </script>
<?php } ?>

<?php if (isset($_REQUEST['msg']) && $_REQUEST['msg'] == 2) { ?>
  <script>
    Swal.fire(
      'Oops...',
      'Something went wrong!!',
      'error'
    ).then(() => {
      window.location.href = "profile_setting.php";
    });
  </script>
<?php } ?>
<?php
require("footer.php")
?>