Helping ordinary people create extraordinary websites!
HOME TUTORIALS SCRIPTS WEB HOSTING BLOG FORUM
Get Our Newsletter
Email:

Web Database Access from Desktop Applications

By Michael J. Ross
2008-05-06


Desktop Application Access

Even though PHP is rarely used for desktop applications, for the purposes of consistency, we will consider a test application written in PHP. Here is a function for checking whether or not the user's installation of your program has expired:

function validate_program_license( $registration_number ) {
$expiration_date = file_get_contents(
"http://www.example.com/product_expiration_date.php?
registration_number=$registration_number" );

if ( substr( $expiration_date, 0, 5 ) == 'Error' ) {
exit( 'Error: problem accessing database' );
}
if ( strtotime( $expiration_date ) < date() ) {
exit( 'Error: program license has expired' );
}
}

Presumably, you would call this function in your PHP desktop application to confirm that the user's license is still valid. For instance:

if ( strtotime( validate_program_license( $registration_number ) ) < date() ) {
exit( 'Error: program license has expired' );
}

In a production environment, the registration number could be stored in a hidden license file created when the user downloads and installs your application, or perhaps in the Windows Registry.



Tutorial Pages:
» Web Database Access from Desktop Applications
» Sample Database
» Database Access Script
» Desktop Application Access
» Database Updating
» Conclusion


Related Tutorials:
» Zend Framework Tutorial
» Port Scanning and Service Status Checking in PHP
» CubeCart 3.0 Installation and Configuration
» PHP Site Search Made Easy
» Installing and Configuring Drupal 6.1
» Desktop Application Development with PHP-GTK

Ask A Question
characters left.