<?php
	ob_start();
	session_start();

	

	//Include Files

	include("../class/admin.php");

	include("../class/dbConnection.php");

	

	//Declaring Variables

	$adminId;

	

	//Retrieving Session Variable

	if(isset($_SESSION["adminId"]))

	{

		$adminId = $_SESSION["adminId"];

		//echo $adminId;

		//Creating 'dbConnection' Object

		$dbObj = new dbConnection();

		$con = $dbObj->getConnection();

		//echo $con . "<br/>";

		

		if($con)

		{

			//echo "MySQL Server Connected<br/>";

			$dbResult = $dbObj->selectDatabase();

			if($dbResult)

			{

				//Creating 'admin' Object

				$adminObj = new admin();

				$adminObj->setSignOutTime($adminId,$con);

				unset($_SESSION["adminId"]);//Value Becomes Null

				session_destroy();

				header('Location:index.php?message=Signed%20Out%20Successfully');

			}

			else

			{

				echo mysql_errno() . " : " . mysql_error();

			}

		}

		else

		{

			echo mysql_errno() . " : " . mysql_error();

		}

	}

	else

	{

		header('Location:index.php?message=Unauthorised%20Access%20Prohibited');

	}

	

?>