<? 
session_start();
require("DB.php");
if($userType != 'm')
	header("Location: logout.php");

require("asstHeader.php");
?>
<html>
<h1>Users</h1>

<?
$dbVar = new DB("andromeda", "gradinfo");
if(connectDB()){
		global $dbVar;
		if(isset($actionflag) && isset($event_id)){

			if($actionflag == 1){
				$result = $dbVar->deleteUser($event_id);
				print $result;
			}
		}
		getUser();
}

function connectDB(){
	global $dbVar;
	if (!$dbVar->connect()) {
		print "Error";
		return false;
	}
	else return true;
}

function getUser(){
	global $dbVar;
	$listOfUsers = ($dbVar->getListUsers());
	print"<table border = 1><tr>\n";
	print"<tr><td>First Name</td><td>Last Name</td>
		<td>Middle Initial</td><td>User Id</td><td>Password</td>
		<td>email</td>";
	
	foreach($listOfUsers as $row)
	{
		print"<tr>\n";
		print"<td>$row[firstName]</td>
			<td>$row[lastName]</td>
			<td>$row[userId]</td>
			<td>$row[password]</td>
			<td>$row[email]</td>
			<td><a href=\"$GLOBALS[PHP_SELF]?event_id=$row[userId]&actionflag=1\">
			delete</a></td>";
		print "<tr>\n";

	}
	print"</table>";
	print"<form action = \"newStudent.php\" method= \"post\">
	      <input type=\"submit\", value=\"Update User\"></form>";
	print"<hr>";
}

$dbVar->disconnect();
?>
</html>
