Jump to content
Larry Ullman's Book Forums

Bob

Members
  • Posts

    8
  • Joined

  • Last visited

Posts posted by Bob

  1. Hello HartleySan,

     

    The environment is: Apache 2.2, PHP 5.2, MS Expression Development Server.

     

    I've tried in IE9, FF 15.0.1, Chrome 22.0xxxx.

     

    I tried sending a function header('WWW-Authenticate: Basic realm="Test Authentication System"'); It worked okay.

     

     

    The problem is only with the redirect. I also ensured that the BOM for UTF-8 was turned off (to prevent any hex characters being sent ahead of the header). Unfortunately, I've decided to use some javascript code for the redirect, this seems to work satisfactorily. One day, if I ever determine the problem with the PHP header redirect, I'll post on this forum.

     

    Thanks again for all of the time you have taken on my behalf,

     

    Bob

  2. Thanks for your response Rob.

     

    I have checked and ensured (php.ini) that the error reporting was on. I've checked and rechecked for any whitespace before the header call. The script I'm using was copied (cut and pasted) directly from the author's online script.

     

    As frustrating as this is, there does not seem to be any apparent problem (although I know there is something causing the problem).

     

    Thanks

  3. HartleySan,

     

    I tried this (using index1.php and index2.php). The echo came back as "This is index1.php." (this is the file I had the header() on). The problem still exists. I tried it also on another site I maintain (different directory) and it also did not work. Finally, I loaded the 2 files to the production server (my host provider) and it did not work there either.

     

    I've never been so confused!

     

    Thanks for trying

  4. Thank you HartleySan,

     

    I have tried every possible combination of path to welcome.php. Welcome.php is in the same directory as login.php. (however, I still tried every possible path). The ob_start() function is called in an include file (per the instructions in the book I am following). And, as you have pointed out, the server config is not an issue since I've tested it many times. (I even loaded it to my host server and the same problem exists).

     

    I'm certain it is a small error, but I cannot find it after 5 hours of work.

     

    Thanks for your reply.

  5. Hello,

     

    Following the guidance in chpt. 8 of this great book, I am unable to get the header () function to redirect to the welcome.php page ('Location: welcome.php');.

     

    I've tried every possible combination of paths to the welcome.php page, and all I get when clicking the login button is a blank page (still titled "login"). I've tried it on my development platform with the latest versions of Apache, and PHP. I even tried it on my host (bluehost.com). Lastly, out of frustration, I cut and pasted every one of the examples from the downloaded scripts (in case I made an error in reproducing what I see in the book), all to no avail. Every other feature that chapter 8 calls for works perfectly. The login page, with the redirect is shown below: (see the code about half-way down the page).

     

    Thanks for your help!

     

     

    <?php // Script 8.13 - login.php #2

    /* This page lets people log into the site (in theory). */

    // Set the page title and include the header file:

    define('TITLE', 'Login');

    include('templates/header.html');

    // Print some introductory text:

    print '<h2>Login Form</h2>

    <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 ($_SERVER['REQUEST_METHOD'] == 'POST') {

    // Handle the form:

    if ( (!empty($_POST['email'])) && (!empty($_POST['password'])) ) {

    if ( (strtolower($_POST['email']) == 'me@example.com') && ($_POST['password'] == 'testpass') ) { // Correct!

     

    // Redirect the user to the welcome page!

    ob_end_clean(); // Destroy the buffer!

    header ('Location: welcome.php');

    exit();

     

    } else { // Incorrect!

    print '<p>The submitted email address 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 an email address and a password!<br />Go back and try again.</p>';

     

    }

    } else { // Display the form.

    print '<form action="login.php" method="post">

    <p>Email Address: <input type="text" name="email" size="20" /></p>

    <p>Password: <input type="password" name="password" size="20" /></p>

    <p><input type="submit" name="submit" value="Log In!" /></p>

    </form>';

    }

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

    ?>

×
×
  • Create New...