Web Database Access from Desktop Applications
By Michael J. Ross2008-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:
|
|
|||||||||
You might also want to check these out:
|
Leave a Comment on "Web Database Access from Desktop Applications"
You must be logged in to post a comment.
Link to This Tutorial Page!

