<?php
    header
"content-type: application/x-javascript; charset=TIS-620" );

    
/**  Configuration  */
    
require_once("../configuration.php");
    require_once( 
"../includes/connMySQL.class.php" );
    
    
/**  Create Database Object  */
    
$conn = new DBConn;

    
$sql "SELECT * FROM user_tb  WHERE Username = '".$_REQUEST["username"]."' AND Flag = '0'";
    
$result $conn->execQuery($sql);

    if(isset(
$_REQUEST["btnStatus"]) && $_REQUEST["btnStatus"] == "1"){
        if(
mysql_num_rows($result)){
            echo 
"<input name=\"btnCreateUser\" type=\"submit\" class=\"TEXT-DARK-BLUE10\" id=\"btnCreateUser\" value=\"ยืนยันข้อมูล\" style=\"cursor:pointer\" disabled>";
        }
        else{
            if(
strlen($_REQUEST["username"]) > 3) echo "<input name=\"btnCreateUser\" type=\"submit\" class=\"TEXT-DARK-BLUE10\" id=\"btnCreateUser\" value=\"ยืนยันข้อมูล\" style=\"cursor:pointer\">";
            else echo 
"<input name=\"btnCreateUser\" type=\"submit\" class=\"TEXT-DARK-BLUE10\" id=\"btnCreateUser\" value=\"ยืนยันข้อมูล\" style=\"cursor:pointer\" disabled>";
        }
    }
    else{
        if(
mysql_num_rows($result)){
            echo 
"<br><font color='red'><strong>มีชื่อผู้ใช้นี้แล้วในระบบ</strong></font>";        
        }
        else{
            if(
strlen($_REQUEST["username"]) > 3) echo "<br><font color='green'><strong>ท่านสามารถใช้ ชื่อผู้ใช้นี้ได้</strong></font>";
            else echo 
"<br><font color='red'><strong>ชื่อผู้ใช้มีขนาดน้อยกว่า 3 ตัวอักขระ</strong></font>";
        }
    }

    
/**  Free Resource */
    
$conn->freeresult($result);
    
    
/**  Close the Database  */
    
$conn->disconn();
    
    
/**  Unset Class  */
    
unset($dbObj);
?>