<?php
session_start(); 
	
	if(!isset($_SESSION['tulsilogin']))
	{
		header('Location: index.php');
		return;
	}
	
	
	$_SESSION['_token']=bin2hex(openssl_random_pseudo_bytes(16));
	
	include("connect.php");
	include("mylibrary.php");
	

	$statusmid=$_POST['statusmid'];
	$statustype=checkvalidstring($_POST['statustype']);
	$statusname=checkvalidstring($_POST['statusname']);
	/* $statusname=removespecialchar($statusname); */
	
	
	$eve = "select * from res_status_master where statusname='$stagename' and statustype='$statustype' and statusmid !=$statusmid";
	$re = mysqli_query($conn, $eve);
	if(mysqli_num_rows($re) > 0)
	{
		$_SESSION['msg1'] = "Sub Status Already Inserted.";
		header('Location: stage.php');
	}
	else
	{
	$eve1 = "update res_status_master set statustype='$statustype',statusname='$statusname' where statusmid=$statusmid";	
	if ($conn->query($eve1) === TRUE)
	{
			
		$_SESSION['msg'] = "Record has been updated successfully";
	}
	else
	{
		$_SESSION['msg1'] = "Error";
	}
	}
	header('Location: status.php');
?>