Home arrow PHP arrow Page 3 - User Management in a PHP Invoicing System

Emailing reminders - PHP

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.

TABLE OF CONTENTS:
  1. User Management in a PHP Invoicing System
  2. The Action column
  3. Emailing reminders
  4. User settings page
By: Leidago
Rating: starstarstarstarstar / 6
September 27, 2006

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

When a invoice remains unpaid for a set amount of time you can send an email as a reminder to the client. This option is available when you view the list of unpaid invoices. So, create a new PHP document and save it as emailInv.php. Then add the following code:

Code 8 emailInv.php

<?
ob_start();
include "config.php";
$query="SELECT email FROM client where id='".$u_id."'";
$result1 = mysql_query($query);
            if (!$result1) {
               $error = mysql_error();
}else{
while ($row = mysql_fetch_array($result1)) {
$em= $row["email"];
}
}
$query="SELECT * FROM invoices where invno='".$u_id."'";
$results=mysql_query($query);
if(!$results){
exit(mysql_error());
}
 while ($row = mysql_fetch_array($results)) {
                $invNo=$row["invno"];
                $dte=$row["inv_date"];
              $dte=date("d/m/Y");
                                                     }
$query_invdetails = "SELECT * FROM clientinv WHERE finv='".$invNo'";
if(!$result_invdetails= mysql_query($query_invdetails)){
echo mysql_error();
}else{
$num_invdetails = mysql_num_rows($result_invdetails);
$invdetails=mysql_fetch_assoc($result_invdetails);}
$emailAd=your@emailaddress;
$subj="RE: Overdue Invoice Reminder.";
$mess="Product Description: $invdetails['descr']crn";
$mess .="Invoice Number: $invNorn";
$mess .= "Invoice Date: $dtern";
$mess .="Total (incl. VAT): $invdetails['totwVAT']rn";
$mess .="If you have any queries or problems please do not hesitate to contactrn";
$mess .=" your@emailaddress ";
$from=" your@emailaddress
$to=$em ;//Client email address
if (mail($to,$subj,$mess,$from)){
header("location:Main.php?act=success");
}else{
echo "Could not send mail. Please check your mail settings";
}
?>

A client ID is sent to this script from the unpaid.php page and is then used to retrieve the email address and other information of the client. The script runs three queries; each of them retrieves data related to a particular invoice. The first query interrogates the client table and retrieves the client email address. The second query retrieves the invoice number and the date of the invoice. And finally, the third query retrieves the invoice description and cost.  This information is then used to create an email message, and then sent off.  



 
 
>>> 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 5 - Follow our Sitemap

Dev Shed Tutorial Topics: