Script 15.9 AJAX script for login

Server side PHP script called from javascript 15.10 used to validate the login form asynchronously.

Output
INCOMPLETE
Source
<?php # Script 15.9 - login_ajax.php
// This script is called via Ajax from 15.8.php.
// The script expects to receive two values in the URL: an email address and a password.
// The script returns a string indicating the results.

// Need two pieces of information:
if (isset($_POST['email'], $_POST['password'])) {

	// Need a valid email address:
	if (filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) {
		
		// Must match specific values:
		if ( ($_POST['email'] == 'email@example.com') && ($_POST['password'] == 'testpass') ) {
	
			// Set a cookie, if you want, or start a session.

			// Indicate success:
			echo 'CORRECT';
			
		} else { // Mismatch!
			echo 'INCORRECT';
		}
		
	} else { // Invalid email address!
		echo 'INVALID_EMAIL';
	}

} else { // Missing one of the two variables!
	echo 'INCOMPLETE';
}

?>