<?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");


	
	$rolemid=$_POST['rolemid'];
	$rolename=checkvalidstring($_POST['rolename']);
	
	$tt="";
	
	
$eve = "select * from res_role_master where rolename='$rolename' and rolemid !='$rolemid'";
	$re = mysqli_query($conn, $eve);
	if(mysqli_num_rows($re) > 0)
	{
		$_SESSION['msg1'] = "Role Already Inserted.";
		header('Location: role.php');
	}
	else
	{	
	$eve1 = "update res_role_master set rolename='$rolename' $tt where rolemid='$rolemid'";

	

	if ($conn->query($eve1) === TRUE)

	{		

		$_SESSION['msg'] = "role Record Updated succesfully";

		header('Location: role.php');		

	} 

	else 

	{

			

		$_SESSION['msg'] = "Error";

		header('Location: role.php');

	}
	}

?>