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


	
	$eventmid=$_POST['eventmid'];
	$eventname=checkvalidstring($_POST['eventname']);
	$eventmessage=checkvalidstring($_POST['eventmessage']);
	
	$tt="";
	/* if(empty($_FILES['attechment']['name']) == false  )
	{
		$attechment = date("YmdHis").$_FILES['attechment']['name'];
		$path = "docs/";
		move_uploaded_file( $_FILES['attechment']['tmp_name'], $path ."/". $attechment );
	
		$tt = ",attechment='$attechment' ";
	} */

	
$eve1 = "select * from res_event_master where eventmessage='$eventmessage' and eventmid!='$eventmid'";
	$re1 = mysqli_query($conn, $eve1);
	if(mysqli_num_rows($re1) > 0)
	{
		$_SESSION['msg1'] = "event Already Inserted.";
		header('Location: event.php');
	}
	else
	{
	$eve = "update res_event_master set eventname='$eventname',eventmessage='$eventmessage' $tt where eventmid='$eventmid'";

	

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

	{		

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

		header('Location: event.php');		

	} 

	else 

	{

			

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

		header('Location: event.php');

	}
	}

?>