<?php session_start();?>
<?php
include('dbcon.php');
error_reporting(0);
session_start();
$username=$_SESSION['login'];

//for blank session
if($username=="")
{
	//echo"<script>alert('You has Logged Out.Please Login!..');
		// window.location.href='index';</script>"; //redirect user to login page
}

if(isset($_POST['submit']))
{
	$op=$_POST['oldpass'];
	$np=$_POST['newpass'];
	$cp=$_POST['confirmpass'];
	if($np!=$cp)
	{
		echo"<script>alert('New & Confirm Password do not Match! Try Again...');</script>";
	}
	else
	{
		$query=mysqli_query($con,"SELECT password from tbl_admin where password='$op'");
		if(mysqli_num_rows($query)>0)
		{
			$result=mysqli_query($con,"update tbl_admin set password='$np' where password='$op'");
			if($result==true)
			{
				  echo"<script>alert(' Ohh Yes! Password change successfully');</script>";

			}
			else
			{
				echo  "<script>alert('Sorry, Invalid Current Password!...');</script>";
			}
		}
		else
		{
			echo  "<script>alert('Old and Current Password do not Match! Try Again...');</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, shrink-to-fit=no"/>
  <meta name="description" content=""/>
  <meta name="author" content=""/>
  <title>Admin || Change Password</title>
  <!--favicon-->
  <link rel="icon" href="assets/images/favicon.ico" type="image/x-icon">
  <!-- Bootstrap core CSS-->
  <link href="assets/css/bootstrap.min.css" rel="stylesheet"/>
  <!-- animate CSS-->
  <link href="assets/css/animate.css" rel="stylesheet" type="text/css"/>
  <!-- Icons CSS-->
  <link href="assets/css/icons.css" rel="stylesheet" type="text/css"/>
  <!-- Custom Style-->
  <link href="assets/css/app-style.css" rel="stylesheet"/>
  
  
  
   <style>
   
   body{
    background-image:url(images/bgg.jpg);   
       
       
   }  
      
  </style>
  
  
</head>

<body class="bg-dark">
    
   
 <!-- Start wrapper-->
 <div id="wrapper">
                                                  
                                                  
                                                <!--button--->  
                                                  <div class="feature-btn" style="margin-right:10px;">
                                                        <a href="dashboard.php">
                                                            <span class="button-text" style="background-color:black; color:white;">Dashboard</span>
                                                            <i class="far fa-long-arrow-right"></i>
                                                        </a>
                                                    </div>
                                                <!--button-->
    
	<div class="card card-authentication1 mx-auto my-5">
	    
	 
		<div class="card-body">
		    
		 <div class="card-content p-2">
		       
		 <div class="text-center">
		     <a href="index.php" style="font-weight: 600;color:#4285f4;font-size:40px"> MGS</a>
		 		<!--<img src="images/deltalogo.png" alt="logo icon"  style="width:75%;">-->
		 	</div>
		  <div class="card-title text-uppercase text-center py-3">Change Password</div>
		    <form method="POST">
			  <div class="form-group">
			   <label for="exampleInputPassword" class="">Current Password</label>
			   <div class="position-relative has-icon-right">
				  <input type="password" id="exampleInputPassword" class="form-control input-shadow" name="oldpass" placeholder="Enter Old Password">
				  <div class="form-control-position">
					  <i class="icon-lock"></i>
				  </div>
			   </div>
			  </div>
			  <div class="form-group">
			   <label for="exampleInputPassword" class="">New Password</label>
			   <div class="position-relative has-icon-right">
				  <input type="password" id="exampleInputPassword" class="form-control input-shadow" name="newpass" placeholder="Enter New Password">
				  <div class="form-control-position">
					  <i class="icon-lock"></i>
				  </div>
			   </div>
			  </div>
			  <div class="form-group">
			   <label for="exampleInputPassword" class="">Confirm Password</label>
			   <div class="position-relative has-icon-right">
				  <input type="password" id="exampleInputPassword" class="form-control input-shadow" name="confirmpass" placeholder="Enter Confirm Password">
				  <div class="form-control-position">
					  <i class="icon-lock"></i>
				  </div>
			   </div>
			  </div>
			  
			   <!--<div class="form-group">
			     <div class="icheck-material-primary">
                   <input type="checkbox" id="user-checkbox" checked="" />
                   <label for="user-checkbox">I Agree With Terms & Conditions</label>
			     </div>
			    </div>-->
			  
			 <button type="submit" name="submit" class="btn btn-primary shadow-primary btn-block waves-effect waves-light">Change Password</button>
			  
			  <!--div class="text-center mt-3">Sign Up With</div>
			  <div class="form-row mt-4">
			  <div class="form-group mb-0 col-6">
			   <button type="button" class="btn btn-facebook shadow-facebook btn-block text-white"><i class="fa fa-facebook-square"></i> Facebook</button>
			 </div>
			 <div class="form-group mb-0 col-6 text-right">
			  <button type="button" class="btn btn-twitter shadow-twitter btn-block text-white"><i class="fa fa-twitter-square"></i> Twitter</button>
			 </div>
			</div>-->
			
			 </form>
			 
		   </div>
		   
		  </div>
		  <!--<div class="card-footer text-center py-3">
		    <p class="text-muted mb-0">Already have an account? <a href="index"> Sign In here</a></p>
		  </div>-->
	     </div>
    
     <!--Start Back To Top Button-->
    <a href="javaScript:void();" class="back-to-top"><i class="fa fa-angle-double-up"></i> </a>
    <!--End Back To Top Button-->
	</div><!--wrapper-->
	
  <!-- Bootstrap core JavaScript-->
  <script src="assets/js/jquery.min.js"></script>
  <script src="assets/js/popper.min.js"></script>
  <script src="assets/js/bootstrap.min.js"></script>
  
</body>
</html>
