Creating the Main Pages of a PEAR CMS - Code Explained
(Page 2 of 4 )
The first part of the script has PHP code that deals with determining if a user has the right to view it. The code itself is very simple; first, it calls the ob_start() function, which will prevent the "headers already sent" error message. Then it calls the session_start() function to open up a session. It does this because this piece of code uses the application-wide session variable called "author_name" to determine whether or not it should redirect the user to the login page. This will happen if the user is not authenticated.
<?php
ob_start();
session_start();
if(!isset($_SESSION['author_name'])){
//redirect to login page
header("location:login.php");
}
?>
The next part of the code simply builds the HTML for the page:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">