<?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 ($accessID = login($username,$password)){
$valid_user = $username;
$_SESSION['valid_user'] = $valid_user;
$_SESSION['accessID'] = $accessID;
header ("Location: mainpage.php");
exit;
}
else{ // no array fetch
$msg = "Either Username or Password is invalid!";
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();
}
?>