<?php

include_once '../AutoLoader.php';
AutoLoader::registerDirectory('../src/classes');
require "config.php";
if (empty($_SESSION['user'])) {
    header("Location: ../index.php");
    die("Redirecting to index.php");
}
if (!empty($_POST)) {
    $admin = new AdministratorInfo();
    // Update session variables to reflect post values.
    $postParams = array('first_name', 'last_name', 'sex', 'address', 'city', 'state', 'zip', 'phone', 'challenge_question_id', 'challenge_question_answer');
    foreach ($postParams as $param) {
        $_SESSION['user'][$param] = htmlspecialchars($_POST[$param]);
    }
    if ($admin->validate($_POST)) {
        $admin->saveInfo($_POST, $_SESSION, $db);
    }
}
?>

<!doctype html>
<html lang="en">
<head>
    <style>.error {color: #FF0000;}</style>
    <meta charset="utf-8">
    <title>Hospital Management</title>
    <meta name="description" content="Hospital management system for Intro to Software Engineering">
    <meta name="author" content="WAL Consulting">
 function test_paramsSize()
 {
     $admin = new AdministratorInfo();
     $queryParams = $admin->getQueryParams(null, null);
     $this->assertEquals(count($queryParams), 12);
 }