Location: PHPKode > scripts > Handle remote data with PHP 5 and REST Web service > handle-remote-data-with-php-5-and-rest-web-service/server/restserver_update.php
<?php
	// check if classes are valid
	$strKlasse = '';
	function __autoload($strKlasse)
	{	try {	if(!preg_match('=^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$=m',$strKlasse))
		{ throw new Exception("Class '$strKlasse' is not valid."); }
		$strIncludeFile = 'classes/'.$strKlasse. '.class.php';
		if (!file_exists($strIncludeFile))
		{ throw new Exception("Include file <i>$strIncludeFile</i> not found.<br>"); }
		require_once($strIncludeFile);
		if(!class_exists($strKlasse))
		{ throw new Exception("Include file <i>$strIncludeFile</i>
							contains no class '$strKlasse'.<br>");	}
		return true; }
		catch(Exception $e)
		{ die($e->getMessage()); }
	}

	// set class instance for error handling
	$processlogin = new ServerLoginData();

	$id = '';
	$user = '';
	$pw = '';
	$account = '';
	$ipaddress = '';

	$id = $_POST['id'];
	$action = $_POST['action'];
	$user = $_POST['user'];
	$pw = $_POST['pw'];

	$account = $_POST['account'];
	$acclength = strlen($account);

	$ipaddress = $_POST['ipaddress'];

	// determine action based on POST
	if(isset($action)
		&& $action == 'doupdate'
		&& (ctype_alnum($account))
		&& $acclength == '13') {

		// set variable for specific submission action and class instance
		$storedata = new ServerActiveRecord($id,$delid=0,$user,$pw,
										$account,$ipaddress);
		$storedata->prepareData();
		$storedata->store();
	} else {
		echo $processlogin->get_error();
	}

  ?>
Return current item: Handle remote data with PHP 5 and REST Web service