<?php
include_once('../helpers/init.php');
if(isset($_POST['changePassword'])){
	$old_password = $_POST['old_password'];
	$new_password = $_POST['new_password'];
	$cnf_password = $_POST['cnf_password'];
	$username = $_SESSION['username'];
	if(login($username,$old_password)){
		if($new_password != $cnf_password){
			header('Location:../pages/settings.php?result=failer&message=Password do not match');	
		}else{
			if(changePassword($username,$new_password)){
				header('Location:../pages/settings.php?result=success&message=Password successfully Changed!');
			}else{
				header('Location:../pages/settings.php?result=failer&message=Unable to change the password');
			}
			
		}
		
	}else{
		header('Location:../pages/settings.php?result=failer&message=Old Password Incorrect');	
	}
}
?>