User Registration

For this example, we are using the "onblur" handler to check their login name. Try "admin" to see how the response is if the name isn't available. Make up something else to see the response of it being available.

 

Contents of "checkLogin.php" script:

<?php
/********************************************
* Check Username Availability
********************************************/

//get the desired username
$login = $_GET['login'];

// array of taken names
// would be handled differently if checking a database
$used = array ('admin','patrick','modernblue','ferris-bueller');

//check to see if it's available
if(in_array($login,$used)) {
     echo "<span class=\"sorry\" id=\"response\">That username has already been registered.</span>";
} else {
     echo "<span class=\"success\" id=\"response\">That username is available!</span>";
}

//trigger the validation function
echo '<script type="text/javascript"> validLogin() </script>';

?>