<html><body><center>


<?
$valid = false;
if (isset($_REQUEST['submitted']))
{
	$username = $_REQUEST['user'];
	$password = $_REQUEST['password'];
	// This should be checked in the database instead
	if ($username == "iyad" && $password == "207")
		$valid = true;
	if ($valid)
	{
		// If the user is not in the session (e.g. first visit), add him
		if (!isset($_SESSION['user']))
        		$_SESSION['user'] = "$username";
		else
		{
			// If the user is already in the session, retrieve him
        		$username = $_SESSION['user'];
        		echo "Welcome $username<br>";
		}
		echo <<< HERE
			<form name="form2" action="with_forms_see_images.php" method="post">
			<input name="user" type="hidden" value="$username">
			<input type="submit" value="See Images">
			</form>
			 <form name="form3" action="with_forms_upload_images.php" method="post">
                        <input name="user" type="hidden" value="$username">
                        <input type="submit" value="Upload Images">
                        </form>
			 <form name="form4" action="with_forms_logout.php" method="post">
                        <input name="user" type="hidden" value="$username">
                        <input type="submit" value="Logout">
                        </form>

HERE;
	}
	else
		echo "Invalid username or password.<br>\n";
}
else // Display the form
{
echo <<< HERE
	<form name="form1" action="" method="post">
	Enter username: <input name="user" type="text" size="10">
	Enter password: <input name="password" type="password" size="10">
	<input type="hidden" name="submitted" value="true">
	<input type="submit" value="SUBMIT">
	</form>
HERE;
}
?>

</center></body></html>
