Location: PHPKode > projects > PHP Trivia > php-trivia/main.php
<?php	
// ***************************************************************************
// *
// * PHP Dynamic Trivia -- Add your own trivia file.
// * Copyright (C) 2005  Robin van de Vusse (hide@address.com)
// * 
// * This program is free software; you can redistribute it and/or
// * modify it under the terms of the GNU General Public License
// * as published by the Free Software Foundation; either version 2
// * of the License, or (at your option) any later version.
// * 
// * This program is distributed in the hope that it will be useful,
// * but WITHOUT ANY WARRANTY; without even the implied warranty of
// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// * GNU General Public License for more details.
// * 
// * You should have received a copy of the GNU General Public License
// * along with this program; if not, write to the Free Software
// * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
// *
// ***************************************************************************
require_once "config.php";

if (strlen(trim($strSessionPath)) > 0)
	session_save_path($strSessionPath);

session_start();

$boolError = false;
$strName = "";
$strMessage = "";
$intCounter = 1;

if (empty($_SESSION))
{
	$boolError = true;
	$strName = "";
}
else
{
	if (strlen(trim($_SESSION['message'])) > 0)
	{
		$strMessage = $_SESSION['message'] . "<br>\n";
		$_SESSION['message'] = "";
	}
	
	if (strlen(trim($_SESSION['name'])) > 0)
	{
		$boolError = false;
		$strName = $_SESSION['name'];		
	}
	else
	{
		$boolError = true;
		$strName = "";
	}
}

if ($boolError)
{
	$_SESSION['name'] = "";
	$_SESSION['message'] = "You must log in to proceed.";
	header("Location: index.php");
	exit;
}
?>

<html>
<head>
<title>Trivia</title>
</head>

<body>

<table width='800'>
	<tr>
		<td width='160'><table></table></td>
		<td width='640' align='center'>
			<table>Trivia</table>
		</td>		
	</tr>
</table>

<hr>

<table width='800'>
	<tr>
		<td width='160' valign='top' align='center' STYLE='background-color: #9999cc;'>
			<table>
				<tr><td STYLE='background-color: #ccccff; color: #000000;'><a href="options.php" accesskey='o'>[<span STYLE="color: red">O</span>ptions&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;]</a></td></tr>
				<tr><td STYLE='background-color: #ccccff; color: #000000;'><a href="logout.php" accesskey='l'>[<span STYLE="color: red">L</span>ogout&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;]</a></td></tr>
				<tr><td STYLE='background-color: #ccccff; color: #000000;'><a href="highscores.php" accesskey='h'>[<span STYLE="color: red">H</span>ighscores]</a></td></tr>
			</table>
		</td>
		<td width='640' align='center'>
			<table>
<?php
echo "Welcome " . $strName . "!<br>\n";
echo $strMessage . "<br>\n";
?>

<?php
				foreach ($strTriviaTables as $game)
				{
					echo "<tr><td STYLE='color: #000000'><a href='question.php?strTriviaTable=" . $game[0]. "' accesskey='$intCounter'><span STYLE='color: red'>$intCounter</span>. " . $game[1] . "</a></td></tr>\n";
					$intCounter++;
				}


?>
			</table>
		</td>
	</tr>
</table>

<?php require_once "footer.php"; ?>
</body>
</html>

<script type="text/javascript">
<!--
document.onkeypress=keyevent;

function keyevent(e)
{
	var c;
	
	c=String.fromCharCode(window.event.keyCode).toUpperCase(); 	
	target=window.event.srcElement;
	
	if (c == 'O') { window.location='options.php';; return false; }
	if (c == 'L') { window.location='logout.php';; return false; }
	if (c == 'H') { window.location='highscores.php';; return false; }
	
<?php	
$intCounter = 1;

foreach ($strTriviaTables as $game)
{
	echo "if (c =='$intCounter') { window.location='question.php?strTriviaTable=$game[0]';; return false; } \n";
	$intCounter++;
}
?>
}
//-->
</script>
Return current item: PHP Trivia