Creating the Public Template

Before I get into the heart of the public side, I’ll need to create the requisite HTML header and footer files. I’ll whip through these quickly, since the techniques involved should be familiar territory by this point in the book.

To make header.html:

1.
Create a new PHP document in your text editor (Script 13.3).
<?php # Script 13.3 - header.html
2.
Begin the session.
session_start();
?>
It’s very important that the user’s session is maintained across every page, so I’ll start the session in the header file. If the session is not kept consistent, then a new session would begin on subsequent pages, and the user’s history (such as the contents of the shopping cart) would be lost.
3.
Create the HTML head.
 <!DOCTYPE ...

Get PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.