<?php
// include function files for this application
require_once("referrals_fns.php");
session_start();
header("Cache-control: private");
do_html_header("Resource Director Administration Menu");
if ($_POST['username'] || $_POST['passwd'])
// they have just tried logging in
{
$admin_user = $_POST['username'];
$passwd = $_POST['passwd'];
// if they are in the database register the user id
// login() declared in user_auth_fns.php
$login = login($admin_user, $passwd);
// value of 0 means error connecting to the database
if ($login == 0)
{
echo_db_error();
exit();
}
// value of 1 means the user/password pair exists
elseif ($login == 1)
{
// Create a new session value
session_register('admin_user');
// Register the input with the value
$_SESSION['admin_user'] = $admin_user;
// check_admin_user() if from user_auth_fns.php
if (check_admin_user()) {
display_admin_menu();
}
else
{
echo "You are not authorized to enter the administration area.";
}
do_html_footer();
}
// value of 2 means the user/password pair does not exist
elseif ($login == 2)
{
// unsuccessful login
echo "Incorrect username or password. <p>
You must be logged in to view this page.<p>";
do_html_footer();
exit;
}
}
// If $login/$password aren't being sent, login isn't being initiated
// so display the admin window
else
{
// check_admin_user() if from user_auth_fns.php
if (check_admin_user()) {
display_admin_menu();
}
else
{
echo "You are not authorized to enter the administration area.";
}
do_html_footer();
}
?>