PHP
  Home arrow PHP arrow User Management in a PHP Invoicing Sys...
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

User Management in a PHP Invoicing System
By: Leidago
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 3 stars3 stars3 stars3 stars3 stars / 5
    2006-09-27

    Table of Contents:
  • User Management in a PHP Invoicing System
  • The Action column
  • Emailing reminders
  • User settings page

  • 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


    User Management in a PHP Invoicing System


    (Page 1 of 4 )

    In this fourth and final article covering the creation of a PHP invoicing system, we're going to put together the user management section. In this section we will be able to view all available users and do all the associated things like deleting or updating user details. We are also going to be able to add new users.
    Three downloadable files are available for this article; you can access them here, here, and here.

    Let's start by showing how we are going to list all the users in the database. Create a new PHP document and save it as allusers.php. On this page we are going to display user names and full names.

    But before we do anything else, let's create the query that will retrieve all the user details from the database. On the very top of the page add the following code:

    <?
    include "config.php";
    $query_users = "SELECT uid, uname, fname,lname  FROM users ORDER BY uid
    DESC";
    $result_users = mysql_query($query_users);
    $num_users = mysql_num_rows($result_users);
    ?>

    As a matter of good coding practice, not to mention security, I have not retrieved the password of the user at this stage. It will be retrieved only when the user wants to view his/her profile, later on.

    So let's create a table with the above headers as well as a column with "action" as its header:

    <tr class="tblheadings">
              <td><strong>User  Name</strong> </td>
                               <td><strong>Full Name </strong></td>
    <? if($_SESSION['level'] =="admin" ) {  ?>
                               <td><strong>Action</strong></td>
                               <? }?>        </tr>

    For security reasons I've added a condition on when the action column can be displayed. The column should only be shown if the person who is logged in is an administrator. This will prevent non-admin users from changing any important information. If you just want to view or change your details, then you should go to the "User settings link."

    Next we will built a dynamic table based on the results from the query:

    <?
                            if($num_users > 0){
                            while($users= mysql_fetch_assoc
    ($result_users)){
                            ?>
            <tr class="tblinfo">
              <td><?=$users['uname'];?> </td>
                            <? if($_SESSION['level'] =="admin" ) {  ?
    >
                              <td><a href="uprofile.php?uid=<?=$users
    ['uid']?>">View Full Details </a> |<a href="delusers.php?uid=<?
    =$users['uid']?>">Delete</a> <a href="uprofile.php?uid=<?=$users
    ['uid']?>">Edit</a></td>
                                <? }?>
            </tr>
                            <? } 
                            }else{?>
                            <tr>
                            <td colspan="2"><p>There are currently no
    users details available.</p></td>
                            </tr>                       

                            <? }?>

    I've put in place the same security barrier as before, so please take note.

    The above code retrieves and builds a dynamic table by checking whether the results of the query returned any rows, as in:

    if($num_users > 0){
                            while($users= mysql_fetch_assoc
    ($result_users)){
                            ?>

    If there are rows returned, a 'while()' loop is called, and the rows and cells for the retrieved data are created. In the event that there are no users, the following is displayed:

    }else{?>
                            <tr>
                            <td colspan="2"><p>There are currently no
    users details available.</p></td>
                            </tr>
                            
                           
    <? }?>

    Below is a screen shot of a users page:

    More PHP Articles
    More By Leidago


       · The user management module, helps to manage users of the invoice system. Let me...
       · Where is the sql file to create the database, I didn't see it in the...
       · YES, i've download the bill1.zip file, but i didn't found the .SQL file. i didn't...
       · i have downloaded the bills.zip but it doesnt have its sql, please kindly help me...
     

       

    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 2 hosted by Hostway
    Stay green...Green IT