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.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 login and error handling
	$processlogin = new ServerLoginData();

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

	$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 == 'dologin'
			&& (ctype_alnum($account))
			&& $acclength == '13') {

			// valid user login data
			echo $processlogin->validUserLogin($user,$pw,$account,$ipaddress);

	} else {
		echo $processlogin->get_error();
	}

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