Hi all. So I was almost done with my second PHP book when I got dreadfully stalled last week.
BACKGROUND:
The book has been building up, and I'm in Chapter 11 with an "application" that allows users to log-in and it demonstrates several concepts including: using includes, templates, and cookies.
While the book has been good, I think the author's coding practices are really loopy in this chapter and don't make good use of organizing code and/or files.
I now have a handful of PHP pages, and I honestly do not understand how they are supposed to work together?! 😕😕
I have typed in the code verbatim, but I get two big problem areas:
PROBLEMS:
1.) The included Header template file stopped working.
2.) When I use a valid username/password in my database, the Log-In fails and I get all of these error messages complaining about "the header was already sent"?!
I have followed Larry Ullman's code to a "T", and I think the issue is bad code design plus some bugs in the book SIGH
SUMMARY OF FILES:
Attached is a ZIP of all relevant files, plus my directory structure, plus script to create the database.
Here is a brief summary of each file:
0802_MysqliConnect.php - provides database connection information.
style_2.css - CSS stylesheet.
0303_Footer.html - template provides a website header.
1101_Header.html - template provides a website footer.
1101_LoginPage.inc.php - prints any errors associated with logging in, as well as creating the log-in form.
1102_LoginFunctions.inc.php - defines two functions used by the log-in/log-out process.
1103_Login.php - processes the log-in form submission, and upon successful log-in, the user is redirected. Two included files are necessary.
1104_LoggedIn.php - user is redirected here from "1103_Login.php". If no cookie is present, redirect the user.
Additional Files...
The files above built off of these files below from Chapter 8 and 9...
0800_Index.php
0901_ViewUsers.php
0902_DeleteUser.php
0903_EditUser.php
0905_ViewUsers.php
and all of these Chapter 8 and 9 files worked just fine (e.g. Header was working previously).
SUMMARY:
Obviously it would be easier to help me debug things if you all had Larry Ullman's "Visual QuickPro Guide: PHP 6 and MySQL 5". However, since you don't, and since you can't look on my MacBook, the best I could do was explain things in detail here and include a ZIPPED copy of the files and folders.
I could really use some help here so I can finish learning how to work with "Cookies" and then move onto "Sessions" and finish up the book!! :o
(I have been stalled on this issue since last week!)
Thanks,
Amy