I am pulling my hair out trying to create an If statement that will check an xml file to see if a person has submitted a payment within the last 30 days.
I have a PHP file that will display information from an xml file as a .png. Before that image renders I would like to run an If statement against another xml file to see if the person has paid in the last 30 days. Basically if I have a payment $from $username (these would be matching eg $from= bob and $username= bob) and the $date is within the 30days then display dynamic image else display a different image.
EDIT: I'm not quite sure if it matters but this will be located in the same file that generates a dynamic PNG via PHP.
Here is an example of the payment database.
<PaymentsByMonthYear>
<Payment>
<Id>51180698</Id>
<Date>2015/02/02 15:23:27</Date>
<To>Company</To>
<From>Jim</From>
<Amount>1000.00</Amount>
<Location>null</Location>
<Comment>null</Comment>
</Payment>
<Payment>
<Id>51180698</Id>
<Date>2015/01/15 15:23:27</Date>
<To>Company</To>
<From>Bob</From>
<Amount>1000.00</Amount>
<Location>null</Location>
<Comment>null</Comment>
</Payment>
<Payment>
<Id>51180698</Id>
<Date>2014/12/02 15:23:27</Date>
<To>Company</To>
<From>Steve</From>
<Amount>1000.00</Amount>
<Location>null</Location>
<Comment>null</Comment>
</Payment>
So far all I have that reliably works is the connection to the XML file
<?php
//Check payment
//Connect to payment server
$link = "http://ift.tt/1LEuv6w";
$xml = simplexml_load_file($link) or die("Error: Cannot create object");
//Gather Fields
foreach($xml->children() as $payment_info)
{
$date = $payment_info->Date;
$from = $payment_info->From;
$amount = $payment_info->Amount;
}
All i really need to verify is that a payment was made by the person trying to access the file, and possibly the amount in the future.
Thanks a lot for any help!
Aucun commentaire:
Enregistrer un commentaire