<?php
ob_start();
session_start();
include_once('../connect.php');
if(!isset($_SESSION['username']))
{
header('location:login.php');
}
?>
<?php
$subject = $blog = '';
$id = 0;
if(isset($_GET['edit']))
{
$id = $_GET['edit'];
$sql = mysqli_query($db,"SELECT * FROM blogs where id = '$id'") or die(mysqli_error($db));
$row = mysqli_fetch_array($sql);
$subject = $row['subject'];
$date = $row['date'];
$blog = $row['blog'];
}
?>
<!DOCTYPE html>
<html>
<title>PCC</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js" integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6" crossorigin="anonymous"></script>
<body>
<?php include_once("edit_menu.php"); ?>
<div class='container-fluid'>
<h3>Change Password</h3>
<br>
<form class="pb-3" action="#" method="post">
<div class="form-group">
<input type="text" name='old_password' class="form-control" autofocus placeholder="Your Old Password*" required>
<input type="text" name='new_password' class="form-control" placeholder="Your New Password*" required>
<input type="text" name='confirm_password' class="form-control" placeholder="Confirm New Password*" required>
</div>
<input type='submit' name='submit' class="btn btn-danger" value='Reset Password'/>
</form>
</div>
<div id='footer'>
<p align="center" style="background-color:#000;color:#fff">Developed by Findjee Infotech : 7869555421 / 8319726227</p>
</div>
</body>
</html>
<?php
//CHANGE OLD PASSWORD
if(isset($_POST['submit']))
{
$new_password = $_POST['new_password'];
$old_password = $_POST['old_password'];
$confirm_password = $_POST['confirm_password'];
if($old_password == $_SESSION['password'])
{
if($confirm_password == $new_password)
{
$sql = mysqli_query($db,"update admin set password = '$new_password' where id = '1'");
echo "<p align='center' class='alert alert-success'>Your password has been changed successfully</p>";
}
else
{
echo '<p align="center" class="alert alert-warning">Passwords do not match !!!</p>';
}
}
else
{
echo "<p align='center' class='alert alert-danger'>You have entered wrong Old Password </p>";
}
}
?>