PHP
  Home arrow PHP arrow Page 2 - Time Is Money (part 2)
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Forums Sitemap 
IBM® developerWorks 
Sun Developer Network 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Mobile Linux 
App Generation ROI 
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

Time Is Money (part 2)
By: The Disenchanted Developer, (c) Melonfire
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 4
    2001-11-16

    Table of Contents:
  • Time Is Money (part 2)
  • Getting Creative
  • Split Personality
  • In...
  • ...And Out
  • The Number Game
  • Exercising Restraint
  • The Big Picture...
  • ...And The Little Brush Strokes
  • When Things Go Wrong
  • Happy Endings

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb 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


    Time Is Money (part 2) - Getting Creative


    (Page 2 of 11 )

    If you look at the main menu, you'll see that the third menu item allows the user to view entries for a specified date. When you analyze this a little, though, you'll see that this menu item has broader implications - it must allow the user to:

    view a list of timesheet entries for the specified date;

    add new entries for the specified date;

    delete existing entries from the list.

    In order to perform these functions, the script - I've called it "view.php" - must necessarily receive a valid datestamp (created from the variables $d, $m and $y). These three variables are generated from the drop-down boxes in "menu.php" - you may remember this from last time's article (if not, I'd strongly suggest you review the source code for "menu.php" and then come back here). Once "view.php" receives these values, it generates a datestamp, checks to ensure that the date is a valid one, and then queries the "log" table for all relevant data.

    So that takes care of displaying existing entries. But what about adding new ones, or deleting existing ones?

    Well, after much thought and a couple of conversations with our resident interface designer, I've come up with a clever way to combine both these functions into "view.php". Here's a rough sketch of what I have in mind:



    Essentially, I plan to split the page into two main sections. The left side of the page will contain a list of entries retrieved from the database, with a checkbox next to each; the user can select an entry for deletion by checking the corresponding box. The right side of the page will hold a form, which can be used to add new entries to the timesheet. Entries added from the form on the right side will immediately appear in the list on the left side.

    This sounds complicated, but it's actually not all that difficult to implement. The important thing here is to take the pieces one at a time and deal with them separately. And so, the first thing I need to do is set up a page template.

    <? // view.php - view/add/delete entries for a specific date // includes // check for valid user session session_start(); if(!session_is_registered("SESSION_UID")) { header("Location: error.php?ec=1"); exit; } // check for valid date if (!checkdate($m, $d, $y)) { header("Location: error.php?ec=2"); exit; } <html> <head> </head> <body bgcolor="white"> <? // display page header ?> <!-- table (1r, 3c) --> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td valign="top" align="left" width="60%"> <!-- table for existing timesheet records goes here - snip --> </td> <!-- spacer --> <td width="10%"> &nbsp; </td> <td valign="top" align="left" width="30%"> <!-- table for new timesheet records goes here - snip --> </td> </tr> </table> <? // display page footer ?> </body> </html>
    The script begins with the usual checks and includes, and generates an HTML page containing a (1r, 3c) table. The first and last of these cells will be used for the existing and new timesheet data respectively.

    Note the checkdate() function at the top of the script - I'm using this to validate the date value received by "view.php". This check is necessary to catch incorrect date values - for example, 30 February or 31 April. If the date selected by the user is invalid, the script will redirect to the generic error handler, which should display a message indicating the error.

    More PHP Articles
    More By The Disenchanted Developer, (c) Melonfire


     

       

    PHP ARTICLES

    - Working With Different Namespaces in PHP 5
    - User Management Explained: Overview
    - Using Namespaces in PHP 5
    - Database Security: Guarding Against SQL Inje...
    - Building a Modular Exception Class in PHP 5
    - Database and Password Security for Web Appli...
    - Handling MySQL Data Set Failures in PHP 5
    - Building Site Registration for Web Applicati...
    - Intercepting Customized Exceptions in PHP 5
    - Securing Your Web Application Against Attacks
    - Sub Classing Exceptions in PHP 5
    - Authentication for Web Application Security
    - Building a Content Management System with Co...
    - Filters and Login Systems for Web Applicatio...
    - Working with the Email Class in Code Igniter





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
    Stay green...Green IT