<?php session_start();?>
<html>
                
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <title>Licaland QR Code</title>
        <!-- Tell the browser to be responsive to screen width -->
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <script type="text/javascript" src="js/instascan.min.js"></script>
		<!-- DataTables -->
		<link rel="stylesheet" href="plugins/datatables-bs4/css/dataTables.bootstrap4.min.css">
		<link rel="stylesheet" href="plugins/datatables-responsive/css/responsive.bootstrap4.min.css">
		<link rel="stylesheet" href="css/bootstrap.min.css">
    </head>

    <body style="background:#F5F5DC">

        <nav class="navbar" style="background:#fff">
		  <div class="container-fluid">
			<div class="navbar-header">
			  <img src="database/logo.ico" class="navbar-brand" href="#"></img>
			  <a class="navbar-brand" href="#">LICALAND QR ATTENDANCE</a>
			</div>
		  </div>
		</nav>

        <div class="container">
            <i class="glyphicon glyphicon-user"></i> 
            <label>CHANGE PASSWORD</label>
        </div>
        <div class="container">
            <form action="<?php $_SERVER['PHP_SELF']; ?>" method="post" class="form-horizontal" border-radius: 5px;padding:10px;background:#fff;" id="met">
                <div class="form-group">
                    <br>
                    <input type="password" name="change_name" id="change_id" placeholder="Enter New Password" class="form-control" style="width:20em; />
                </div>
                <div class="form-group">
                    <br>
                    <input type="password" name="change_name_auth" id="change_id_auth" placeholder="Confirmation Password" class="form-control" style="width:20em; />
                </div>
                <div class="form-group">
                    <br>
                    <input type="submit" name="change_auth" value="Change Password" class="btn btn-primary submitBtn" style="width:20em; margin:0;" />
                </div>
            
            </form>
        </div>

        <?php
    //session_start();
    $server = "localhost";
                        $username="dtrlicagroup_root";
                        $password="Licaland@123!";
                        $dbname="dtrlicagroup_qrcodedb";

    $conn = new mysqli($server,$username,$password,$dbname);

    if($conn->connect_error){
        die("Connection failed" .$conn->connect_error);
    }

    if(isset($_POST['change_name'])){

        $first = $_POST['change_name'];
        $second =$_POST['change_name_auth'];

        if(strval($first) == strval($second)){
            $sql ="update qrauth set PASSKEY='$second', MODDATE=NOW()";
		    $query=$conn->query($sql);
            echo '<script>alert("Password change successful");</script>';
            echo '<script>window.location.replace("https://dtr.licagroup.net/index.php")</script>';
        }else{
            echo '<script>alert("Please confirm your password");</script>';
        }
      
    }



?>


    </body>
</html>
