<?php 
// functions.php
function check_txnid($tnxid){
    global $link;
    return true;
    $valid_txnid = true;
    //get result set
    //$sql = mysql_query("SELECT * FROM payments WHERE txnid = '$tnxid'", $link);
    //if($row = mysql_fetch_array($sql)) {
    //    $valid_txnid = false;
   // }
    return $valid_txnid;
}
 
function check_price($price, $id){
    $valid_price = false;
    /*
    you could use the below to check whether the correct price has been paid for the product
    if so uncomment the below code
 
    $sql = mysql_query("SELECT amount FROM `products` WHERE id = '$id'");
    if (mysql_numrows($sql) != 0) {
        while ($row = mysql_fetch_array($sql)) {
            $num = (float)$row['amount'];
            if($num == $price){
                $valid_price = true;
            }
        }
    }
    return $valid_price;
    */
    return true;
}
 
function updatePayments($data){
    global $link;
	date_default_timezone_set ("Singapore"); 
	$date=date("d-m-Y", time());
	$time=date("h:i:sa", time());
	
    if(is_array($data)){
        $sql = mysql_query("INSERT INTO license (CompanyID, payment_choice, payment_amount, payment_date, payment_times, payment_status) VALUES (
				'".$data['custom']."' ,
                '".$data['txn_id']."' ,
                '".$data['payment_amount']."' ,
				'".$date."' ,
				'".$time."' ,
                '".$data['payment_status']."' 
                )", $link);
    return mysql_insert_id($link);
    }
}

?>