PHP错误,我不明白

时间:2011-03-06 19:37:15

标签: php

每当我在PHP代码中收到错误时,我最终都会收到新错误。我和PHP一样缺乏经验,所以这个网站对我很有帮助。

我的代码:

<?php

/* This is the location of the file and will be */
/* used as the baseline for all of my files writing */
/* of code within php.*/

/* THIS REQUIRES THE FILES FOR THE APPLICATOIN */
require_once('websiteconfig.inc.php');

/*FUNCTION THE VALIDATE NAME ON FORM */
function validateLogin($emailaddress='', $password='')
{

    /*THIS INIITALLIZES THE EMAIL KEY ON THE FORM */
    $email_key = 'betty@abc.com';
    $password_key = '1234'; 
    $auth_match = 0;

    /*THIS IS THE FIRST STATEMENT TO TEST THE USERNAME AND PASS*/
    if ($emailaddress == $email_key && $password == $password_key) 
    {
    $auth_match=1;
    }

    /*THIS MAKES SURE THAT THE USER NAME AN PASSWORD IS MATCHED*/   
    return $auth_match;
}

function sanitize($form_var)
{
    $clean_data = strtolower(trim($form_var));

    return $clean_data;
}

/*AUTHENTICATION OF LOGON*/

$auth_status = 0;

/*PULLED FROM THE LOGON ON FORM AND DETERMINES IF ON CLICK OCCURED*/
if(array_key_exists('submit', $_POST))
{
/*REMOVES OLD DATA ON LOGON*/
    $emailaddress = sanitize($_POST['emailaddress']);
    $password = sanitize($_POST['password']);

    /*This makes sure that each fiedl was processed correctly*/

    try 
    {
    if($emailaddress == '' || $password == '')
    {
        throw new Exception ('E-mail and password must be provided to log in to this site.  Please  try again.');
    }
    else 
    {
        /* Validate data */
        $auth_status =validateLogin($emailaddress , $password);

        /*this kicks of the exception*/
        try 
        {
            if(!isset($auth_status))
            {
        throw new Exception('Sorry, online banking is not available at this time. Please try again.');

            }
        }
        /*Check validation of password*/

        catch(exception $v) {

        echo 'Message: ' . $v->getMessage();
        exit();
    }

    /*try catch for failed authentication*/

    try
    {
        if($auth_status <= 0) 
        {
        /*through trigger */
        throw new Exception('Sorry, the email address and password does not match our records.  Please try again!');

        } 
        else 
        {
            /*This creates the person object*/
            $currentMember = new Person($auth_status);

            /*set the currentMember atributes*/
            $currentMember->firstname = 'Jenny';
            $currentMember->lastname = 'Ginny';
            $currentMember->emailaddress = 'tommy@twotone.com';
            $currentMember->memberid = $auth_status;

            /*start session*/
            session_start();
            $_SESSION['currentMember'] = serialize($currentMember);
        }
    }
    catch(Exception $a) {
     echo '<h3>Error: ' . $a->getMessage() .'</h3>';
}


/*check validaiton of login  */
catch(Exception $e) 
{
    echo 'Message: ' . $e->getMessage();
    exit();
}

if($auth_status == 1)
{
    /*THE LOGON IS SUCCESSFUL*/
    echo '<table width="400" border="1" align="center"><tr> <td><h3>Welcome Back, Betty!...  Your not ugly after all</h3></td></tr> </table>' . "\n\n";
    echo "\t" . '<table width="400" border="1" align="center"><tr> <td><li><a href="' .     URL_ROOT . 'onlinebanking" title="Online Banking">On Line Banking</a></li></td></tr> </table>' . "\n\n";

} 
elseif($auth_status == 0) 
{
    /*THIS OCCURS IF THE LOGON FAILS*/
    echo '<table width="400" border="1" align="center"> <tr> <td> <h4     class="error">Authentication Error please try again! </h4></td></tr> </table>' . "\n\n";
echo '<table width="400" border="1" align="center"><tr> <td><p> Please make sure that the <strong> "Numbers Lock" </strong>or "<strong>Caps Lock"</strong> is not on and re-type your password.</p>&nbsp;</td> </tr> </table>'; 
}

?>

1 个答案:

答案 0 :(得分:1)

如果您没有收到任何错误,请填写以下内容:

<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
 /*YOUR CODE*/
?>