<? session_start();

/*********************************************************
* filename: checkLogin
* Purpose: Checks for valid user login from the cs425 database
*	   Go to 'page.php' if the login passwrd pair is valid
* Version information
* Date: November 5, 2001
* Copyright notice
***********************************************************/


//** Include database class definition */
require("DB.php");

//** Create instance of database and connect to database */
$db = new DB("andromeda","gradinfo");
$db->connect();
$firstName = $lastName = "";
$user = new User();
$user->username = $username;
//echo $user->username ;
$user->password = $pwd;
$num = $db->checkValidUser($user);
if($num != 0){
	$firstName = $user->name->firstName;
	$lastName = $user->name->lastName;
  session_register('firstName');
  session_register('lastName');

//** Direct user to a page indicating valid login */
 $validLogin = 1;
 $userType = $user->userType;

 session_register('validLogin');
 session_register('username');
 session_register('userType');
 header("Location: page.php");

}

//** Invalid login, redirect to login form, display a message */
else{
 $invalidLogin = 1;
 session_register('invalidLogin');
 header("Location: login.php");
}

?>
