<?php
require_once("func_all.php");
$db=db_connect();
if (!$db) {
echo "<center> Error connecting to database. </center>\n";
exit;
}
session_start();
if ($submit) {
if (!$username || !$password ){
$msg = "You did not fill in all the fields!";
display_login_form($msg);
exit;
}
else{// both fields are filled in
if ($myprincipalid = login($username,$password)){
$principal_valid_user = $username;
session_register("myprincipalid");
session_register("principal_valid_user");
setcookie ("myprincipalid", $myprincipalid,time()+7200);
setcookie ("principal_valid_user", $principal_valid_user,time()+7200);
header ("Location: mainpage.php");
exit;
}
else{ // no array fetch
$msg = "Either username/password is incorrect or User account has expired.";
display_login_form($msg);
exit;
}// end of else no array fetch
}//else end of both fields are field in
}// end of if $submit
else {
display_login_form(); //login_form();
}
?>