<?php 

// Include main file
include_once('../libs/main.php');

// Check admin Login
include_once('checkLogin.php');

$successMsg = '';

if(isset($_REQUEST['successMsg'])){
	$successMsg = $_REQUEST['successMsg'];
}

if(isset($_REQUEST['failedMsg'])){
	$failedMsg = $_REQUEST['failedMsg'];
}

// Logical section of page
$adminObj =  new  admin();

if(!isset($_REQUEST['admin_id']) || intval($_REQUEST['admin_id'])==0){
	header('Location:adminlist.php');
	exit;
}

if(isset($_POST['submit'])){
	
	if($_POST['admin_password']==$_POST['admin_repassword']){
		
		$adminData->admin_id	 	= $_POST['admin_id'];	
		$adminData->admin_password 	= md5($_POST['admin_password']);
			
		$rs = $adminObj->changePassword($adminData);
		if($rs){
			$successMsg ="Admin Password changed successfully";			
			header('Location:adminlist.php?successMsg='.$successMsg);
			exit;
		}
	}else{
		$failedMsg = "Password and Again password do not matched.";
	}
}

// Include Template 
include_once('../libs/routs.php')

?>