<?
session_start();
session_unregister('aF');
session_unregister('aF1');

if($userType != 'm')
  header("Location: logout.php");

require("DB.php");
require("asstHeader.php");


$dbVar = new DB("andromeda", "gradinfo");
$dbVar->connect();



if(isset($actionflag) && isset($event_id)){

			if($actionflag == 1){		
				deleteStudent($event_id);
				deleteUser($event_id);
			  $actionflag = 0;
			}
//	printStudents();
}
printStudents();
function printStudents()
{
	print"<h1>Graduate Students in Computer Science</h1>";

	global $dbVar;
	$listOfStudents = ($dbVar->getListStudents());
	print"<table border = 1><tr>\n";
	print"<tr><td>First Name</td><td>Last Name</td><td>Student Number</td>";
	foreach($listOfStudents as $row)
	{
		//print $row["firstName"]." ";
		//print $row["GRE"];
		print"<tr>\n";
		print"<td>$row[firstName]</td><td>$row[lastName]</td>
			<td>$row[rNumber]</td><td> </td><td><a href=\"viewS.php?event_id=$row[rNumber]\">
			Update / View  </a></td>
			<td> </td><td><a href=\"javascript: if (window.confirm('Delete Student from database?')) 
			document.location = '$GLOBALS[PHP_SELF]?event_id=$row[rNumber]&actionflag=1';\">";
		print "delete</a> </td><td> </td><td> </td>";
		print "<td> <a href=\"addCourseForm.php?event_id=$row[rNumber]\">
			Course</a> </td><td> </td>";
	
		print "<td> <a href=\"addProjectForm.php?event_id=$row[rNumber]\">
			Project</a> </td><td> </td>";
		print "<tr>\n";
	}
	print"</table>";
	print"<form action = \"s.php\" method= \"post\">
	      <input type=\"submit\", value=\"Add a new student\"></form>";
	print"<hr>";
}

function deleteStudent($id)
{
	global $dbVar;
	$dbVar->deleteStudent($id);
}

function deleteUser($id){
	global $dbVar;
	$dbVar->deleteUser($id);

}
?>