Building an Authors Page for a PEAR CMS - The Code Explained
(Page 2 of 4 )
The script starts by making the usual checks concerning the status of the currently logged-on user. The checks are done in this way: a session is started, using PHP’s session_start() function, which starts or opens a session. Currently our session contains only two variables, the author_name and the access level of a user.
The security check that is done by the script uses the author_name session variable that is available to the entire application. It checks to see if that variable is set or if it exists. If the variable is set, then it means that the currently logged-in user is authenticated and should be allowed to view the page. On the other hand, if the session variable is not set, the user will be redirected to the login page:
<?php
session_start();
if(!isset($_SESSION['author_name'])){
//redirect to login page
header("location:login.php");
}
?>
The next part of the page starts to build the HTML portion of the script. The HTML code will also include a table that will eventually host the dynamic content that we want to display:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">