Home arrow PHP arrow Page 5 - Client Management for a PHP Invoicing System

Adding a new client - PHP

What's an invoicing system that can't manage the data for the clients you're invoicing? This article, the third of four parts, shows how to make managing your clients easy. This part of the system allows you to view a full list of client names, and add, update or remove clients from your database.

TABLE OF CONTENTS:
  1. Client Management for a PHP Invoicing System
  2. Building a table
  3. Deleting clients and viewing their details
  4. Updating client information
  5. Adding a new client
By: Leidago
Rating: starstarstarstarstar / 15
September 20, 2006

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

To add a new client, I created a form that takes the following information:

  • Client name
  • Address
  • Email
  • Phone number
  • Contact Name

Below is a screen shot of what the form looks like.

Here's the HTML for the form:

<table width="100%" border="0" cellspacing="1" class="block">
             <tr>
             <td>
             <table width="100%" height="19" border="0">
            <tr class="heading">
              <td><a href="Main.php" class="link">[MENU]</a></td>
              <td>USER:</td>
              <td><a href="logout.php"
class="link">LOGOUT</a></td>
            </tr>
          </table>             

             </td>
             </tr>
        <tr>
          <td height="34" colspan="2">
            <form  name="newc" action="NewClient.php"
method="post">
<table width="100%" border="0">
  <tr>
    <td>&nbsp;</td>
    <td><? if(isset($msg)){ echo $msg;}?></td>
  </tr>
  <tr>
    <td width="122"><span class="style1"> Company Name
</span></td>
    <td width="426"><input name="name" type="text" id="name"
size="90"></td>
  </tr>
  <tr>
  <td>Address</td>
  <td><?php
$sBasePath = 'FCKeditor/' ;
$oFCKeditor = new FCKeditor('address') ;
$oFCKeditor->BasePath         = $sBasePath ;
//$oFCKeditor->Value             = 'This is some <strong>sample
text</strong>. You are using <a
href="http://www.fckeditor.net/">FCKeditor</a>.' ;
$oFCKeditor->Create() ;
?></td>
  </tr>
  <tr>
    <td>Email</td>
    <td><input name="email" type="text" size="90"></td>
  </tr>
  <tr>
    <td>Phone</td>
    <td><input name="phone" type="text" size="90"></td>
  </tr>
  <tr>
    <td>Contact name </td>
    <td><input name="contact_name" type="text" id="contact_name"
size="90"></td>
  </tr>
  <tr>
    <td colspan="2"><div align="center" class="style1">
      <input name="submit" type="submit" id="submit"
value="Submit New Client">
    </div></td>
  </tr>
</table>
</form>
</td>
</tr>

</table>

Once the form is submitted, the following code handles the form data:

<? include "FCKeditor/fckeditor.php";
include "config.php";
if(isset($_POST['submit'])){
$query_ins = "INSERT INTO client SET name='".trim(addslashes
($_POST['name']))."',address='".trim(addslashes($_POST
['address']))."',";
$query_ins .= "date_added = '".$td."',email = '".trim(addslashes
($_POST['email']))."',";
$query_ins .= "contact_name = '".trim(addslashes($_POST
['contact_name']))."',phone_no = '".trim(addslashes($_POST
['phone']))."'";
if(mysql_query($query_ins)){
header("location:allclients.php");
}else{
echo mysql_error();
}
}
?>

All that the code above does is match the form data to the table fields and send it to the database, after which the user is sent back to the allclients page.

Conclusion

Client management is the third in the series on creating a invoicing system. The system makes managing your clients easy by allowing you to view a full list of client names and also allowing you to update or remove clients from your database. 



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

blog comments powered by Disqus
   

PHP ARTICLES

- PHP Closures as View Helpers: Lazy-Loading F...
- Using PHP Closures as View Helpers
- PHP File and Operating System Program Execut...
- PHP: Effects of Wrapping Code in Class Const...
- PHP: Building Concrete Validators
- Sanitizing Input with PHP
- Executing Shell Commands with PHP
- Handling File Data with PHP
- File Security and Resources with PHP
- ArrayObject PHP Class Examples
- ArrayObject PHP Class: An Introduction
- Getting File System Data with PHP
- PHP Tools for Working with the File and Oper...
- Working with the File and Operating System w...
- PHP Proxy Patterns: Completing a Blog


© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 8 - Follow our Sitemap

Dev Shed Tutorial Topics: