How to execute a PDO Prepared Statement Query Example with MySQL
I recently decided to make the switch to using MySQL PDO Prepared Statements for my database queries. I wanted to add an additional layer of protection against SQL injection and PDO prepared statements are a perfect solution. When used properly PDO prepared statements are an excellent defense against SQL injections.
Continue reading “PHP MySQL PDO Prepared Statement Query Example”
How to Google Geocode an Address with PHP
I have a properly listing site I support that allows users to search for properties within a distance from a specific zip code. Providing a search by zip code is very simple. Providing a search for a given distance from a specific zip code is also pretty simple if you have the geographic coordinates of the target zip code. This is where Google’s Geocoding service comes in handy.
Continue reading “PHP Google Geocode an Address Example”
How to Process PayPal Instant Payment Notification (IPN) with PHP
I have worked on numerous sites that had a need to collect either a one-time payment or establish a recurring (subscription) payment. I always recommend PayPal for collecting payments. PayPal not only offers the ability to make payment with PayPal but also allows non-PayPal buyers to pay with a debit or credit card. There is no charge to join PayPal and no monthly fee to use their service. There is only a charge when you receive a payment. Most clients I work with like not having to pay until you use it.
Continue reading “PHP Process PayPal Instant Payment Notification (IPN) Example”
How to Process Lending Tree Personal Loan Lead Request with PHP
For one of my sites, I had the opportunity to write an interface to process the Lending Tree Personal Loan request. Processing the Lending Tree Personal Loan request is pretty straightforward. For my site, we receive the request, parse the XML, store the lead values in the database, respond to the request with an ACK, make a decision as to whether or not to extend an offer, then prepare and send either an offer or no offer response.
We store the lead information in the database so if the lead reviews our offer and follows the link (we provided in our offer) to complete the application we can retrieve their information from our database and prepopulate our application form. This results in fewer steps required for the lead to complete the application process. The link we provide in our offer includes query string values to identify the lead so we can obtain the lead information from our database. For this example, the function fnPutLeadInfo() has been included in the source below as a placeholder.
The steps are: Get the post, parse the XML, update our database, send the ACK, make a decision, send either the offer or non-offer response.
The logic to make a decision has been omitted. For our example, the variable $offer has been set to false. You would need to add logic to make a decision whether or not to extend an offer to the lead.
For portability I’ve created separate functions for parsing the XML, building the ACK, updating the database, building the offer, building the non-offer, and sending the offer XML.
Continue reading “PHP Process Lending Tree Personal Loan Request Example”
How to Process Indeed.com Job Listing Interface with PHP
I’ve worked on a few job recruiting and job listing sites and a few of those sites have requested the ability to show Indeed.com job listings.
The following example is a stand-alone page that will prompt the user for various search criteria then present matching Indeed.com job listing results.
At the bottom, I’ve included some paging in the event the job listing results are more than will fill a page. In order to maintain our search criteria, I’ve included the search criteria in the paging links. This way we can obtain the search criteria from the search form when posted or from the paging links when they are clicked.
Continue reading “PHP Process Indeed.com Job Listing Interface Example”
How to create a simple Microsoft Excel spreadsheet with PHP only
I’ve had the need to create many spreadsheet exports over the years for various clients and found the simplest way to do it without having to install specific libraries or third party software is to just create the spreadsheet with plain PHP.
The following script will create a comma delimited excel spreadsheet named spreadsheet_name.xls. When you browse to the page with this script the page will produce the export and provide a link to open it.
Continue reading “PHP Simple Microsoft Excel Spreadsheet Example”
How to display a Google Pie Chart with PHP
Pie charts are a great way to display data in an appealing manner. Google charts are easy to implement and offer the user a colorful, interactive experience. The user can hover over sections of the chart to reveal specifics. The following example shows how to render a very simple Google donut style pie chart with two simple values. Our chart will show loan balance amount and loan paid amount effectively displaying the progress made against the loan.
Google offers a variety of charts each with the ability to customize the colors, values, sizes, etc. Reference Google Charts for more information.
Continue reading “PHP Display Google Pie Chart Example”
How to create a simple Microsoft Word document with PHP only
I’ve had the need to create several word documents over the years for various clients and found the simplest way to do it without having to install specific libraries or third party software is to just create the document with plain PHP.
The following script will create a word document named document_name.doc. When you browse to the page with this script the page will automatically prompt you to open or save the file.
Continue reading “PHP Simple Word Document Example”
How to send email using PHPMailer
For those of you who want to send email via PHPMailer instead of the mail() command, here is a simple script I wrote to facilitate sending email. Because there are so many different areas within a site that can send email messages automatically I have externalized the script and include it when needed.
The script includes logic to monitor for an error from PHPMailer and if found send the email using mail() and send an email to the administrator that PHPMailer failed.
This function accepts an optional file parameter. If the file parameter is passed it will be included in the email as an attachment.
Continue reading “PHP Send Email Via PHPMailer Example”
How to Process the Decision Logic iFrame with PHP
I recently had the opportunity to program the iframe interface with Decision Logic for a client of mine. The process requires an account with Decision Logic. I also recommend you obtain the Starter Kit from Decision Logic. Decision Logic is a third party service used to verify a person based on their banking information. The approach is to present the Decision Logic iframe to the user which collects information from the user and performs a verification process.
You must white list and obtain a unique guid from Decision Logic for each URL that presents the Decision Logic iframe.
Once the user completes the Decision Logic iframe process you can have Decision Logic notify you with the results to a notification URL. This requires some setup within your Decision Logic account.
Continue reading “PHP Process Decision Logic iFrame”