All pastes #483012 Raw Edit

Anonymous

public text v1 · immutable
·published 2007-05-11 15:01 UTC
rendered paste body
<?php
session_start();

if (empty($_SESSION['user'])) {
	header("Location: menu.php");
} else {

	$filename="names.txt";
	$fp = @fopen($filename, 'r'); 
	$classarray=array();
	$yeararray=array();

	if ($fp) {
		while (!feof($fp)) {
	                $line = fgets ($fp);
			list($loginname,$fullname,$classcode,$year) = explode(":", $line);
			
			if ($classarray[$classcode] = NULL) {
				array_push($classarray, $classcode);
			}

			if ($yeararray[$year] = NULL) {
				array_push($yeararray, $year);
			}
		}
	}

echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>";
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-au">

<head>
<meta name="author" content="Michael Andrews" />
<title>PHP Assignment</title>

<link rel="stylesheet" type="text/css" href="style.css" />
</head>

<body>

<div id="menu">

        <h5> Main Menu </h5>

                <div id="links4">
                                <ul>
                                        <li><a href="menu.php">Main Menu</a></li>
                                        <li><a href="topfive.php">Top 5 Logins</a></li>
                                        <li><a href="listnames.php">List Names</a></li>
                                        <li><a href="convertlogins.php">Convert Logins</a></li>
                                        <li><a href="listlogins.php">List Logins</a></l>
                                        <li><a href="listusers.php">List&nbsp; Users</a></li>
                                        <li><a href="logout.php">Log Out</a></li>
                                </ul>
                </div>

</div>

<div id="main">

<h4>List Names:</h4>

<h3>Class Code:</h3>
<form method="post" action="listnames.php">
<select>
<?

foreach ($classarray as $key => $val) {
       	
	echo "<option value=\"$key\">$key</option>";
        	
}

echo "</select><h3>Year:</h3><select>";

foreach ($yeararray as $key => $val) {

	echo "<option value=\"$key\">$key</option>";
}
echo "</select>";
?>
<p class="submit"><input type="submit" value="Submit" name="submit" /></p>
</form>
</div>
</body>
</html>

<?
}
?>