Page 1 of 1

Code producing error message and I can't figure out why

Posted: Sat Jun 19, 2010 7:58 pm
by canadian_angel
I am trying to figure out why when I entered this code correctly I am getting the two error messages at the bottom. Can anyone please help me with this please?

Code: Select all

<?php // Script 8.13 - login.php
// This page lets people log into the site.

// Address error handling.
ini_set ('display_errors', 1);
error_reporting (E_ALL & ~E_NOTICE);

// Set the page title and include the header file.
define ('TITLE', 'Login');
require ('templates/header.html');

// Basic HTML formatting stuff.
print '<div id="leftcontent">
      <h1>Login Form</h1>
<p>Users who are logged in can take advantage of certain features like this, that, and the other thing.</p>';

// Check if the form has been submitted.
if ( isset ($_POST['submit'])) {

// Handle the form.
if ( (!empty ($_POST['username'])) && (!empty ($_POST['password'])) ){

    if ( ($_POST['username'] == 'testing') && ($_POST['password'] == 'testpass') ) { // Okay.

      // Redirect the user to the welcome page!
        header ('Location: welcome.php');
        exit();
        
} else { // Not okay.

print '<p>The submitted username and password do not match those on file!<br />Go back and try again.</p>';

    }

    } else { // Forgot a field.

print '<p>Please make sure you enter both a username and a password!<br />Go back and try again.</p>';

    }

} else {

  // Display the form.
        print '<form action="login.php" method="post"></p>
        Username: <input type="text" name="username" size"20 /><br />
        Password: <input type="password" name="password" size="20" /><br />
        <input type="submit" name="submit" value="Log In!" /></p>
        </form>';

        } // End of main conditional.

        // Complete the HTML formatting stuff.
        print '</div>';

       require ('templates/footer.html'); // Need the footer.

     ?>
ERROR MESSAGES:

Warning: require(templates/header.html) [function.require]: failed to open stream: No such file or directory in .................

Fatal error: require() [function.require]: Failed opening required 'templates/header.html' (include_path='.:/usr/local/lib/php:/usr/local/php5/lib/pear') in ................

Re: Code producing error message and I can't figure out why

Posted: Sat Jun 19, 2010 8:09 pm
by ScottCFR
Did you read the errors at all?

Warning: require(templates/header.html) [function.require]: failed to open stream: No such file or directory in .................

Fatal error: require() [function.require]: Failed opening required 'templates/header.html' (include_path='.:/usr/local/lib/php:/usr/local/php5/lib/pear')

You need to find and add header.html (Be sure to put it in the templates directory)

Re: Code producing error message and I can't figure out why

Posted: Sat Jun 19, 2010 8:28 pm
by canadian_angel
This is the header file and it is in the templates directory,

Code: Select all

<?php // Script 8.11 - header.html

// Turn on output buffering.
ob_start();

?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-Transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
        <title> 
        <?php // Print the page title.
        if (defined ('TITLE')) { // Is the title defined?
        print TITLE;
        } else { // The title is not defined.
           print 'Elliott Smith Fan Club';
        }
        ?>
        </title>

        <style type="text/css">

            body {
            margin:0px 0px 0px 0px;
            background: #9F9;
            }

            #leftcontent {
                float:left;
                width:67%;
                background:#fff;
                border-right:2px solid #000;
                border-bottom:2px solid #000;
                margin-right:15px;
                padding-bottom:20px;
                }

            p,h1,pre {
                margin:0px 30px 10px 30px;
                }

            h1 {
                font-size:14px;
                padding-top:10px
                }

                #rightcontent p {
                   font-size:14px;
                   margin-left:0px;
                }

      </style>
      </head>
    <body>
        
        <!-- BEGIN CHANGABLE CONTENT. -->
        <!-- Script 8.6 - header.html -->
    </body>
</html>

Re: Code producing error message and I can't figure out why

Posted: Sat Jun 19, 2010 11:33 pm
by ScottCFR
Did you change any of the code, at all? If you did you could have caused something that need to be called on to be changed, therefor making your code give an error.