Client Management for a PHP Invoicing System - Adding a new client
(Page 5 of 5 )
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> </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.
| DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware. |