Location: PHPKode > projects > ConPortal > conportal/inc/errors.php
<?
/*
 *  ConPortal - Pomona College ITS scheduling appplication
 *  Copyright (C) 2005-2006  Pomona College
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of version 2 of the GNU General Public License
 *  as published by the Free Software Foundation.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 */

// Functions dealing with error handling in all its glory

function error ($message)
{
	$_SESSION['error'] = true;
	$_SESSION['errorArray'][] = $message;
}

function display_errors()
/*
 * Display any and all errors that may be in $_SESSION['errorArray'], popping
 * them all off the array. Also, reset $_SESSION['error'] to false.
 */
{
    while(!empty($_SESSION['errorArray']))
        print '<p class="warn">'.array_pop($_SESSION['errorArray'])."</p>\n";

    $_SESSION['error'] = false;
}

function redirect_if_error()
/* 
 * If there has been some sort of error recorded, this function sends the user
 * back to the prior page or the index if the HTTP_REFERER isn't set.
 */
{
    if ($_SESSION['error'])
    {
        if (isset($_SERVER['HTTP_REFERER']))
        {
            header("Location: ".$_SERVER['HTTP_REFERER']);
        }
        else
        {
            header("Location: " . BASE_URL . "index.php");    
        }
    }
}

?>
Return current item: ConPortal