HomePHP Building the Index Page for a PHP Email Application
Building the Index Page for a PHP Email Application
In this third part of a four-part article series on building a PHP email application, we will look at the index page. This page is the heart of the application. We will also look at how to handle attachments in a message and how to integrate them into this application.
The login system that we created in the previous article sends the user through to the index page. This page then downloads the messages from the server and displays its headers. The login script also sends the user ID, which is stored in a session variable called $_SESSION['userid']. In this article we will discuss the work done by the index page as well as the pages to which it links. We will also take a brief look at attachments.
Below is a screen shot of the index page:
Index page
The index page displays the newly downloaded messages in a table with five columns. These columns list (among other things) the date, subject and from field of the messages. There are three things that happen in this script. First the mail connection details of the logged-in user are retrieved:
Then based on the user details, the code moves on to make the connection to the mail server and stores the number of retrieved mail messages in the $numEmails variable:
Next, the table is created and the menu and navigation panels are displayed. The navigation panel contains links to the Calendar, Contacts and profile pages. I also attached the user_id variable, which will be used to retrieve the items specific to the user in each of the above folders to the links. When a user clicks on any of these links, they will be taken to the appropriate page: