Jump to content
Larry Ullman's Book Forums

Problem(S) And Solutions For Script 9.3


Recommended Posts

Had a couple issues, was about to post here for help since I was getting frustrated and couldn't figure out, then by luck finally figured things out and thought I'd share:

 

ISSUE #1

 

After filling out the registration form, I was getting an error that said:

 

Error!
The following error(s) occurred:
- You forgot to enter your last name.

Please try again.

 

I made sure all fields were filled out, which they were, yet still had errors.  I did "view source" on the page with the error and all the fields did have values including "last name" which was throwing an error.

 

Turns out there was a syntax issue - instead of correct code shown below:

// Check for a last name
    if (empty($_POST['last_name'])) {
        $errors[] = 'You forgot to enter your last name.';
    } else {
        $ln = trim($_POST['last_name']);
    }

I had actually typed and forgot the underscore in $_POST:

// Check for a last name
    if (empty($POST['last_name'])) {
        $errors[] = 'You forgot to enter your last name.';
    } else {
        $ln = trim($_POST['last_name']);
    }

ISSUE #2

 

After I fixed the above issue, I then stopped getting that error message but then proceeded to get a blank screen (I would get the header, but nothing else after). 

 

Turns out I had the path listed wrong for the database connection script as for practice purposes I just left the script in the same folder as all the other files:

 

Correct code (in my case since I left all files in same directory):

        require ('mysqli_connect.php');  // Connect to the database

Incorrect code (incorrect for my case since I put this script in the same folder as all my other files, instead of doing what was recommended in the book for live sites and placing the file outside of this directory).

        require ('../mysqli_connect.php');  // Connect to the database

After I made sure the path to the database connection script was correct, it worked finally:

 

 

Thank you!

You are now registered. In Chapter 12 you will actually be able to log in!

Link to comment
Share on other sites

 Share

×
×
  • Create New...