To Do List Project: Part 7

I decided to clean up the Update To Do page I’ve been working with to get rid of the debugging information and to put the navigation menu in a more reasonable location. Losing the debug information was trivial but moving the menu turned up something more interesting.

The PHP files that create entire pages included a file named Session.php that set up the session, user, and timeout mechanisms and generated the navigation menu (remember that the screens were utilitarian affair that only served to illustrate the principles of working with MySQL and some PHP, not to look like much, so part of the ongoing work on this project is to pretty things up over time). This file was included at the very top of the relevant page files, meaning that the menu ended up at the very top, also. When I moved the include statement for this file into the middle of the page (in its own, page-wide DIV below the title DIV) it generated the menu there as expected but also an error.

The error arose because the session management setup invokes the session_start() statement, and that statement has to be placed before the HEAD HTML element. If the menu is in the BODY of the HTML that’s obviously below the HEAD, hence the problem.

The solution was to split the statements that generate the menu into their own file so the Session file can stay at the top of the files where it’s required and a NavMenu.php files that can be placed where it needs to be.

This entry was posted in Software and tagged , . Bookmark the permalink.

Leave a Reply