<?php
 	session_start(); 

if(!isset($_SESSION['atcrmsuloginsesion']))
	{
		header('Location: index.php');
		return;
	}
	if($_SESSION['atcrmsutype']!='Superuser'){
			header('Location: index.php');
		return;
	}
	
	include("connect.php");

	$p1=$_POST['password1'];
	$p2=$_POST['password2'];

	$p3 = $_SESSION['latcmumid'];
	$p4 = $_SESSION['latcuemail'];
	
	
	$eve_select="select * from res_mainuser_master where muemail='$p4' and mupassword='$p1'";
	$re_select = mysqli_query($conn, $eve_select);
	if(mysqli_num_rows($re_select) > 0)
	{
		$eve = "update res_mainuser_master set mupassword='$p2' where muemail='$p4' and mupassword='$p1'";
		$re = mysqli_query($conn, $eve);
		
		$_SESSION['msg'] = "Password Updated";
		header('Location: changepassword.php');
	}
	else
	{
		$_SESSION['msg1'] = "Current Password Not Match";
		header('Location: changepassword.php');
	}
?>