Jump to content
Larry Ullman's Book Forums
guvna

Chapter 12: Persue #3 Add Code To Handling Of $Errors

Recommended Posts

Need some directions with this question please:

 

in login.php we have:

// Assign $data to $errors for login_page.inc.php:
$errors = $data;

 

and in login_page.inc.php we have:

// Print any error messages , if they exist:
        if (isset($errors) && !empty($errors)) {
            echo '<h1>Error!</h1>
            <p class="error">The following error(s) occurred:<br />';
            foreach ($errors as $msg) {
                echo " - $msg<br />\n";
            } // End of foreach.
            echo '<\p><p>Please try again.</p>'; // First closing <\p> tag displays in browser or error!
        } // End of errors IF.

 

btw: I get '</p>' displayed on screen with this code along with errors (script 12#1).

 

I need some direction on whether to change login.php to handle each error, to edit login_page_inc.php or both?

 

I tried editing login_page_inc.php but the errors (if there are any) clear too quickly and the redirect script sends me to the home page. I will continue the book but would like to come back and address this.

Share this post


Link to post
Share on other sites

Good question! You would change both files as login.php would need to be updated to create an array of errors and login_page.inc.php would need to be updated to handle an array.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...