Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Nov 2010
    Location
    Washington DC
    Posts
    341
    Thanks
    22
    Thanked 1 Time in 1 Post

    Using PHP to Record payments into database

    Hello:

    Here is an interesting question.

    I have a client payment recording form which retrieves data from a table that has clients balances and other.

    My task with this form is to take payments (which can be payments in full or partial payments). I need to be able to update the originating table with new payments as well as have the ability to record multiple payment to this account.

    Not sure if this is doable with the existing table or will I need a separate table in conjunction with the initial table.

    Currently I'm able to update the originating table in this way:

    PHP Code:
    <?php
    error_reporting
    (0);
    error_reporting(E_ERROR E_WARNING E_PARSE);
    //error_reporting(E_ALL);

    $host "localhost";
    $login_name "23232";
    $password "23232242";

    $link=mysql_connect("$host","$login_name","$password");        
    mysql_select_db("shop"$link); 
    //or die("Could not find database");
    //echo mysql_errno() . ": " . mysql_error(). "\n";

    // define each variable
    if(isset($_POST['submit']))//this defines any variable that are not define below
      
    {
    $edit_sel_id mysql_real_escape_string($_POST['edit_sel_id']);
    $paymentamount $_POST['paymentamount'];
    $paymenttype mysql_real_escape_string($_POST['paymenttype']);
    $paymentref mysql_real_escape_string($_POST['paymentref']);
    $paymentdate mysql_real_escape_string($_POST['paymentdate']);
    $memo mysql_real_escape_string($_POST['memo']);
    $newbalance=$_POST['newbalance'];
    $newbalance"$".''.$newbalance;
    $paymentamount"$".''.$paymentamount;

    if (
    $edit_sel_id == "") echo "! No identifier retrieved";
    else

    $mysql_query=("UPDATE billofservice SET newpayment_date=NOW(), newpayment_amount='$paymentamount', newpayment_type='$paymenttype', 
    paymentref='$paymentref', newpmtmemo='$memo', Balancedue='$newbalance' WHERE id=$edit_sel_id"
    );
    $result=mysql_query($mysql_query);
    if(!
    $result){die("Error: ".mysql_error());
    }
    mysql_close($link);
    }

    ?>
    I need to figure out a plan when partial payments needs to be entered --as this current mechanism would replace exiting fields with new ones.
    Any thoughts!
    Mossa
    Last edited by mbarandao; 12-07-2010 at 02:26 PM. Reason: typo

  • #2
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    You should definitely have a table to store all payments that come in, separate from what the payment gets applied to. Applying payments to invoices should be handled with yet another table that relates payment to invoice. But all this really depends on what system of accounting you're using-- balance forward? open item? What?

  • #3
    Regular Coder
    Join Date
    Nov 2010
    Location
    Washington DC
    Posts
    341
    Thanks
    22
    Thanked 1 Time in 1 Post
    Issue resolved!
    Thanks for all the suggestions...


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •