PHP
  Home arrow PHP arrow Building the Index Page for a PHP Email Application
Dev Shed Forums  
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Smartphone Development  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Mobile Linux  
App Generation ROI  
IBM® developerWorks  
Forums Sitemap  
E-Commerce Hosting  
Linux Web Hosting  
Managed Hosting  
Small Business Hosting  
VPS Hosting  
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid  
Request Media Kit
Contact Us  
Site Map  
Privacy Policy  
Support  
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
PHP

Building the Index Page for a PHP Email Application
By: Leidago
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 8
    2006-11-08


    Table of Contents:
  • Building the Index Page for a PHP Email Application
  • Navigation and Headers
  • Retrieving Messages
  • Attachments

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      error-file:tidyout.log Del.ici.ous error-file:tidyout.log Digg
      error-file:tidyout.log Blink error-file:tidyout.log Simpy
      error-file:tidyout.log Google error-file:tidyout.log Spurl
      error-file:tidyout.log Y! MyWeb error-file:tidyout.log Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article

     
     
    ADVERTISEMENT


    Building the Index Page for a PHP Email Application
    ( Page 1 of 4 )

    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:

    <?php
    session_start();
    include("connect.php");
    //get popserver login credentials
    $query_details = "SELECT * FROM user WHERE user_id = '".$_SESSION
    ['userid']."'";
    $result_details = mysql_query($query_details);
    $num_details = mysql_num_rows($result_details);
    if($num_details > 0 ){
    while($res = mysql_fetch_array($result_details)){
    $pop = $res['pop3'];
    $usname = $res['remuser'];
    $pw = $res['rempass'];
    $email = $res['email'];
    $user = $res['user_id'];
    global $email;
    }
    }else{
    echo mysql_error();
    }

    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:

    if($num_details >0){
    //put popserver details in headers array
                $mbox = "{".$pop.":110/pop3}INBOX";
                $userid = "$usname";
                $userpassword = "$pw";
                if(!$stream = imap_open($mbox, $userid,
    $userpassword)){
                $streamerror = "Connection to server failed";
    }
                if(!$headers = @imap_headers($stream)){
                $header = "No!";
                }else{
                $numEmails = sizeof($headers);
    }
    }
    ?>

    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:

    <table width="100%" border="0" cellspacing="1" class="block">
      <tr class="table">
        <td width="15%" class="table"><a href="NewMsg.php?uid=<?
    =$_SESSION['userid'];?>" class="menu">New Message </a></td>
        <td width="15%"><a href="contacts.php?uid=<?=$_SESSION
    ['userid'];?>" class="menu">Contacts</a></td>
        <td width="12%"><a href="showcal.php?uid=<?=$_SESSION
    ['userid'];?>" class="menu">Calendar</a></td>
        <td width="46%"><a href="profile.php?uid=<?=$_SESSION
    ['userid'];?>" class="menu">Profile </a></td>
        <td width="4%">&nbsp;</td>
        <td width="4%">&nbsp;</td>
        <td width="4%">&nbsp;</td>
      </tr>
    </table>
    <!-- InstanceEndEditable --></td>
      </tr>
      <tr>
        <td width="11%" valign="top"><!-- InstanceBeginEditable
    name="EditRegion4" -->
          <table width="100%" border="0" cellpadding="2"
    cellspacing="1" class="block">
            <tr>
              <td class="table"><strong>Folders:</strong></td>
            </tr>



     
     
    >>> More PHP Articles          >>> More By Leidago
     

       

    PHP ARTICLES

    - Building Dynamic Queries with Chainable Meth...
    - PHP Encryption and Decryption Methods
    - Building a MySQL Abstraction Class with Meth...
    - Completing a Sample String Processor with Me...
    - Mastering WHILE Loops for PHP and MySQL
    - Method Chaining: Adding More Methods to the ...
    - Method Chaining in PHP 5
    - The Role of Interfaces in Applying the Depen...
    - Dependency Injection: Using a Setter Method ...
    - Using a Model Class with the Dependency Inje...
    - Injecting Objects Using Setter Methods with ...
    - Injecting Objects by Constructor with the De...
    - The Dependency Injection Design Pattern in P...
    - Performing Inferential Statistical Analysis ...
    - Performing Descriptive Statistical Analysis ...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 6 Hosted by Hostway
    Stay green...Green IT