<?php
 	session_start(); 

	if(!isset($_SESSION['latcsuperloginsesion']))
	{
		header('Location: index.php');
		return;
	}
	
	if($_SERVER['REQUEST_METHOD'] === 'POST')
	{
		if(!isset($_POST['_token']) || ($_POST['_token']!==$_SESSION['_token'] ) )
		{
			header('Location: index.php');
			return;
		}
	}
	else
	{
		header('Location: index.php');
		return;
	}
	$_SESSION['_token']=bin2hex(openssl_random_pseudo_bytes(16));
	
	
	include("connect.php");

	$umid=$_POST['umid1'];
	
		$ufullname=$_POST['ufullname'];
		$umobile="";
		$userpass=$_POST['userpass'];
		$uemail=$_POST['uemail'];
		$username=$_POST['username'];
		$ugroup="";
		$mumid=$_SESSION['latcmumid'];
	
	if($_SESSION['latcutype']=='mainadmin'){
		$eve = "update res_user_master set ufullname='$ufullname',username='$username',userpass='$userpass',uemail='$uemail',umobile='$umobile',ugroup='$ugroup' where umid=$umid";	
	}
	else{
		$eve = "update res_user_master set ufullname='$ufullname',username='$username',userpass='$userpass',uemail='$uemail',umobile='$umobile',ugroup='$ugroup' where umid=$umid and mumid='$mumid'";	
	}
	if ($conn->query($eve) === TRUE)
	{
			
		$_SESSION['msg'] = "Record has been updated successfully";
		
			
	}
	header('Location: user.php');
?>