<?php
	require_once('source/session.php');
	require_once('source/error.php');
	require_once('source/dbconfig.php');
	require_once('source/dbconfig2.php');
	require_once('source/function.php');
	require_once('source/restrict_admin.php');
	
	if(isset($_POST['post_session']))
	{
		try {
			$session	= strip_tags($_POST['session']);
			
			
			$STH 				= $DBH->prepare("SELECT count(*) FROM tbl_session WHERE session = ?");
			$result 	   		= $STH->execute(array($session));
			$count	  	= $STH->fetchColumn();
			if($count > 0){
			sql($DBH, "UPDATE tbl_session set session = ? WHERE session = ? ", array($session, $session));
			redirect('post_session.php?msg=post');
			exit;
			}else{
			sql($DBH, "INSERT INTO tbl_session (session) VALUES (?)", array($session));
			redirect('post_session.php?msg=post');
			exit;
			}
		}
		catch(PDOException $e) { 
			file_put_contents('PDOErrors.txt', $e->getMessage(), FILE_APPEND); # Errors Log File
				redirect('post_session.php?msg=failed');
		}
	}
	else
	{
				redirect('compose_email.php?msg=failed');
	}
?>