<?php

	$pg = 'home'; 
	$sp = ''; 
	$_SESSION['loginMessage'] = ''; 
	
	if (!empty($_POST['logout'])) {
		$_SESSION['un'] = "";
		//header('Location: '. $URL .'');
	}
	elseif (empty($_SESSION['un'])) {
		if (!empty($_POST['un'])) {
			if ( ($_POST['un'] == $loginInfo['un']) && ($_POST['pw'] == $loginInfo['pw']) ) {
					$pg = 'profile';
					$sp = 'my-requests';
					$_SESSION['un'] = $_POST['un'];
					$_SESSION['loginMessage'] = ''; 
			}
		} else {
			if (!empty($_REQUEST['pg'])) {
				if ( ($_REQUEST['pg'] == 'profile') || ($_REQUEST['pg'] == 'post-a-request') ) {
					$_SESSION['loginMessage'] = '<p class="loginMessage">You Must be logged in to view this page</p>'; 
					header('Location: '. $URL .''); 
				} else {
					$pg = $_REQUEST['pg'];
					$_SESSION['loginMessage'] = ''; 
				}
			}
		}
	} else {
		if (!empty($_REQUEST['pg']))
			$pg = $_REQUEST['pg'];
		if (!empty($_REQUEST['sp']))
			$sp = $_REQUEST['sp'];
		$_SESSION['loginMessage'] = ''; 
	}

?>