<?php
session_start();
include 'include/config.php';

if(!isset($_SESSION['id'])){
    // echo "<script> window.location.href = 'index.php' </script>";
  }
?>

<?php  include 'include/head.php'; 

// $id = $_GET['id'];
// $sel = "select * from `dharmi` where `id`='$id'";
// $qu = mysqli_query($conn,$sel);
// $res = mysqli_fetch_array($qu);




?>
                    
    <!-- Start Content-->
    <div class="container-fluid">
                        
                        <!-- start page title -->
                        <div class="row">
                            <div class="col-12">
                                <div class="page-title-box">
                                    <div class="page-title-right">
                                        <ol class="breadcrumb m-0">
                                            <li class="breadcrumb-item"><a href="dashboard.php">Home</a></li>
                                            <li class="breadcrumb-item active">Change Password</li>
                                        </ol>
                                    </div>
                                    <h4 class="page-title">Chane Password</h4>
                                </div>
                            </div>
                        </div>
                        <!-- end page title --> 

                        <div class="row">
                        <div class="col-12">
                            <div class="card">
                                <div class="card-body">

                    
                    
                    <?php
       if(isset($_POST['submit'])){
     // $username  = $_POST['username'];
      $old_pass  = $_POST['old_pass'];
      $new_pass  = $_POST['new_pass'];
      $con_passs = $_POST['con_passs'];
      
      $selll = mysqli_fetch_assoc(mysqli_query($conn,"select * from `admin`"));
      $pass = $selll['password'];
    //   print_r($pass);
      if($old_pass!==$pass){
          echo "<script>alert('Your Old Password Not Correct');</script>";
      }elseif($new_pass!==$con_passs){
          echo "<script>alert('Your Password Not Match With Confirm Password');</script>";
      }else{
          $updte = mysqli_query($conn,"UPDATE `admin` SET `password`='$new_pass' WHERE `id`='1'");
          if($updte)
          {
              echo "<script>alert('Your Data Updated');</script>";
          }
      }



}
?>
                    <form action=""  method="POST" enctype="multipart/form-data">
                                
                                    <!-- end nav-->
                                    <div class="tab-content">
                                        <div class="tab-pane show active">
                                            <div class="row">
                                                
                                                <!--<div class="col-lg-12">-->
                                                    <!-- Date Range Picker With Times -->
                                                <!--    <div class="mb-3">-->
                                                <!--        <label for="example-select" class="form-label">Username</label>-->
                                                <!--        <input type="text" value="" name="username" class="form-control" placeholder="Username">-->
                                                        
                                                <!--    </div>-->
                                                <!--</div>-->
                                                
                                                <div class="col-lg-12">
                                                    <!-- Date Range Picker With Times -->
                                                    <div class="mb-3">
                                                        <label for="example-select" class="form-label">Old Password</label>
                                                        <input type="text" value="" name="old_pass" class="form-control" placeholder="Old Password">
                                                    </div>
                                                </div>
                                                
                                                <div class="col-lg-12">
                                                    <!-- Date Range Picker With Times -->
                                                    <div class="mb-3">
                                                        <label for="example-select" class="form-label">New Password</label>
                                                        <input type="text" value="" name="new_pass" class="form-control" placeholder="New Password">
                                                    </div>
                                                </div>
                                                
                                                <div class="col-lg-12">
                                                    <!-- Date Range Picker With Times -->
                                                    <div class="mb-3">
                                                        <label for="example-select" class="form-label">Confirm Password</label>
                                                        <input type="text" value="" name="con_passs" class="form-control" placeholder="Confir Password">
                                                    </div>
                                                </div>
                                                
                                                


                                            </div>

                                            <div class="row">
                                                <div class="clearfix"></div>
                                                <div class="col-lg-6">
                                                    <!-- Predefined Date Ranges -->
                                                    <div class="mb-3">
                                                        <input type="submit" class="btn btn-success" value="submit" name="submit">
                                                        
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                        <!-- end preview-->

                                        
                                        <!-- end preview code-->
                                    </div>
                                    <!-- end tab-content-->
                    </form>
                                </div>
                                <!-- end card-body -->
                            </div>
                            <!-- end card-->
                        </div>
                            <!-- end col -->
            </div> <!-- end row-->


                    
    </div> <!-- container -->


<?php  
include 'include/footer.php'; 
?>
            <script src="https://cdn.ckeditor.com/ckeditor5/11.0.1/classic/ckeditor.js"></script>

<!-- editor -->
        // <script src='https://cdn.ckeditor.com/4.13.0/standard/ckeditor.js'></script>
        // <script src='https://code.jquery.com/jquery-3.4.1.min.js'></script>
        // <script id="rendered-js" >
        //     CKEDITOR.replace('editor1');
        //     CKEDITOR.on('instanceReady', function (evt)
        //     {
        //     var editor = evt.editor;

        //     editor.on('change', function (e) {
        //         var contentSpace = editor.ui.space('contents');
        //         var ckeditorFrameCollection = contentSpace.$.getElementsByTagName('iframe');
        //         var ckeditorFrame = ckeditorFrameCollection[0];
        //         var innerDoc = ckeditorFrame.contentDocument;
        //         var innerDocTextAreaHeight = $(innerDoc.body).height();
        //         console.log(innerDocTextAreaHeight);
        //     });
        //     });
            //# sourceURL=pen.js
        </script>
        
        <script>

        ClassicEditor
            .create( document.querySelector( '#editor' ) )
            .catch( error => {
                console.error( error );
            } );
    </script>