<?php
defined('_VALID') or die('Restricted Access!');

require $config['BASE_DIR']. '/classes/filter.class.php';
require $config['BASE_DIR']. '/include/adodb/adodb.inc.php';
require $config['BASE_DIR']. '/include/dbconn.php';

disableRegisterGlobals();

if ( isset($_POST['username']) ) {
    $filter     = new VFilter();
    $username   = $filter->get('username');
    $response   = 'Username empty!';
    if ( $username != '' ) {
        $sql = "SELECT UID FROM signup WHERE username = '" .mysql_real_escape_string($username). "' LIMIT 1";
        $conn->execute($sql);
        if ( $conn->Affected_Rows() == 1 ) {
            $response = 'Username is not available!';    
        } else {
            $response = 'Username is available!';
        }
    }
    
    echo htmlspecialchars($response);
}
?>
