<?php
 	session_start(); 

	if(!isset($_SESSION['tulsilogin']))
	{
		header('Location: index.php');
		return;
	}



	$_SESSION['_token']=bin2hex(openssl_random_pseudo_bytes(16));
	date_default_timezone_set("Asia/Kolkata");
	$mdate= date('Y-m-d H:i:s');
	
	include("connect.php");
include("mylibrary.php");
	$statustype=checkvalidstring($_POST['statustype']);
	$statusname=checkvalidstring($_POST['statusname']);
	/* $statusname=removespecialchar($statusname); */
	
	if($statusname=="")
	{
		$_SESSION['msg1'] = "Status Required";
		header('Location: status.php');
		return;
	}

 $eve = "select * from res_status_master where statusname='$stagename' and statustype='$statustype'";
	$re = mysqli_query($conn, $eve);
	if(mysqli_num_rows($re) > 0)
	{
		$_SESSION['msg1'] = "Sub Status Already Inserted.";
		header('Location: stage.php');
	}
	else
	{
	$eve1 = "INSERT INTO res_status_master (statustype,statusname) VALUES('$statustype','$statusname')";
	if ($conn->query($eve1) === TRUE)
	{
		$_SESSION['msg'] = "Record saved successfully";
	}
	else
	{
		$_SESSION['msg1'] = "Error";
	}
	
	header('Location: status.php');
	}
			
	
?>