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


Database Updating

Up to this point, we have seen how to read data from a remote database. But what if you need to modify data within that database? The same technique can be used, as illustrated in the expanded version of the PHP script below:

require_once 'SQL_functions.php';

if ( ! isset( $_GET[ 'registration_number' ] ) ) {
exit( 'Error: required parameter registration_number is missing' );
}

if ( isset( $_GET[ 'expiration_date' ] ) ) {
$query = SQL_query( 'UPDATE product_registration
SET expiration_date = "' . $_GET[ 'expiration_date' ]
. '" WHERE registration_number = ' . $_GET[ 'registration_number' ] );
if ( ! $query_okay ) {
echo 'Expiration date updated';
}
else {
exit( 'Error: invalid registration_number passed' );
}
}
else {
list( $query_okay, $expiration_date ) = SQL_query( 'SELECT expiration_date
FROM product_registration WHERE registration_number = '
. $_GET[ 'registration_number' ] );
if ( ! $query_okay ) {
exit( 'Error: invalid registration_number passed' );
}
echo $expiration_date;
}
?>

For example, if you want to add another month to Jane's license, the following URL would work: http://www.example.com/product_expiration_date.php?
registration_number=1&expiration_date=2008-06-30



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.