<?php

ob_start();
session_start();

require_once 'includes.php';

require_once("conn.php");

require_once("config.php");

require_once 'dbconfig4.php';

if(isset($_SESSION['admin_user_id'])){

$user_qury=mysqli_query($conn,"SELECT * FROM ormsusers WHERE user_id='$_SESSION[admin_user_id]'");

$user_resalt=mysqli_fetch_array($user_qury);

$customer = $user_resalt['user_id'];
	
$adminbalance = number_format((float)$user_resalt['balance'],2);

if($user_resalt['image']==""){

$image_path="images/empty.jpg";

}

else{

$image_path="../dashboard/images/admin/".$user_resalt['image'];

}

}

if(isset($_POST['change_password'])){
	
	$change=mysqli_real_escape_string($con,$_POST['change']);
	$password=md5(mysqli_real_escape_string($con,$_POST['password']));
	$re_password=md5(mysqli_real_escape_string($con,$_POST['re_password']));
		
	if($password==$re_password){
			mysqli_query($con,"UPDATE ormsregister SET password='$password' WHERE reid='$change'");
			echo "<script>window.location='change_customers_password.php?change=$change&succes';</script>";
	}else{
	echo "<script>window.location='change_customers_password.php?change=$change&fail';</script>";
		
	}

}

?>

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

<head>
	
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width,initial-scale=1">
	<title>Change Password | Recharge and Billing System | ORMS | Dashbaord</title>
	<?php
	require_once 'headercss.php';
	?>
</head>

<body>

    <!--**********************************
        Main wrapper start
    ***********************************-->
    <div id="main-wrapper">
	
<?php
require_once 'header.php';
?>

<!--**********************************
Sidebar start
***********************************-->
<div class="deznav">
<div class="deznav-scroll">
<?php

require_once 'sidebarmenu.php';

?>
</div>
</div>
<!--**********************************
Sidebar end
***********************************-->

        <!--**********************************
            Content body start
        ***********************************-->
        <div class="content-body">
            <!-- row -->
            <div class="container-fluid">
			
                <div class="row page-titles mx-0">
                    <div class="col-sm-6 p-md-0">
                        <div class="welcome-text">
                            <h4>Change Password</h4>
                        </div>
                    </div>
                    <div class="col-sm-6 p-md-0 justify-content-sm-end mt-2 mt-sm-0 d-flex">
                        <ol class="breadcrumb">
                            <li class="breadcrumb-item"><a href="index.php">Home</a></li>
                            <li class="breadcrumb-item active"><a href="#">Password</a></li>
                            <li class="breadcrumb-item active"><a href="change_teacher.php">Change Password</a></li>
                        </ol>
                    </div>
                </div>
				
				<div class="row">
					<div class="col-xl-12 col-xxl-12 col-sm-12">
                        <div class="card">
                            <div class="card-header">
								<h5 class="card-title">Change Password</h5>
							</div>
							<div class="card-body">
							<?php if(isset($_GET['succes'])){ ?>
							<div class="alert alert-success alert-dismissible alert-alt solid fade show">
							<button type="button" class="close h-100" data-dismiss="alert" aria-label="Close"><span><i class="mdi mdi-close"></i></span></button>
							<strong>Success!</strong> Your Password Change Successfully.
							</div>
							<?php } ?>
							<?php if(isset($_GET['fail'])){ ?>
							<div class="alert alert-danger alert-dismissible alert-alt solid fade show">
							<button type="button" class="close h-100" data-dismiss="alert" aria-label="Close"><span><i class="mdi mdi-close"></i></span></button>
							<strong>Error!</strong> Your Password Change Fail.Please Try Again.
							</div>
							<?php } ?>
							

                                <form method="POST">
									<div class="row">
										<div class="col-lg-4 col-md-4 col-sm-12">
											<div class="form-group">	
												<?php if(isset($_GET['change'])){?>
												<input class="form-control" type="hidden" name="change" value="<?php echo $_GET['change']; ?>">	
												<?php } ?>
												<label class="form-label">New Password</label>
												<input class="form-control" type="password" placeholder="Enter New Password" name="password" required>	
											</div>
										</div>
										<div class="col-lg-4 col-md-4 col-sm-12">
											<div class="form-group">
												<label class="form-label">Confirm Password</label>
												<input class="form-control" type="password" placeholder="Confirm New Password" name="re_password" required>	
											</div>
										</div>
										<div class="col-lg-12 col-md-12 col-sm-12">
											<input type="submit" name="change_password" class="btn btn-primary" value="Change Password">
											<a class="btn btn-light" href="home.php"><i class="fa fa-times"></i> Close</a>
										</div>
									</div>
								</form>
                            </div>
                        </div>
                    </div>
				</div>
				
            </div>
        </div>
        <!--**********************************
            Content body end
        ***********************************-->

<?php
require_once 'footer.php';
?>

<!--**********************************
Support ticket button start
***********************************-->

<!--**********************************
Support ticket button end
***********************************-->


</div>
<!--**********************************
Main wrapper end
***********************************-->

<?php
require_once 'footerjs.php';
?>

</body>
</html>