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

?>

<html>
<body>
<?
require("db.php");
require("asstHeader.php");

print session_encode();
print $Student;
$db = new DB("cs425", "Andromeda*");
$link = $db->connect();

$student = $db->getStudent($Student);
//if(isset($actionflag) && ($actionflag == "Update")){
if($submit){	
	$obj = new Student;
	$obj->rNumber = $form[rNumber];
	$obj->firstName = $form[firstName];
	$obj->lastName = $form[lastName];
	$obj->cGPA = $form[cGPA];
	$obj->GRE = $form[GRE];

	//use the proper rNumber for database function
	//in case if it has changed.
	$db->updateStudent($obj, $student[rNumber]);
	$student = $db->getStudent($Student);
}

?>
		
<h1>Student</h1>
<table border = 1>
<!--<form action="display.php"">-->
<form action="<?php print $PHP_SELF;?>">
<input type = "hidden" name="actionflag" value="Update">
<tr><td>R Number</td>
<td><input type="text" name="form[rNumber]" value="<? print $student[rNumber]?>"></td>
<tr><td>First Name</td>
<td><input type="text" name="form[firstName]" value="<? print $student[firstName]?>"></td>
<tr><td>Last Name</td>
<td><input type="text" name="form[lastName]" value="<? print $student[lastName]?>"></td>
<tr><td>Cummulative GPA</td>
<td><input type="text" name="form[cGPA]" value="<? print $student[cGPA]?>"></td>
<tr><td>GRE</td>
<td><input type="text" name="form[GRE]" value="<? print $student[GRE]?>"></td>
<tr><td><input type="Submit" name="submit" value=" Update "></td>
</form></table>
</body></html>

