xajax 클래스

xajax :http://xajax.sourceforge.net
      xajax,     ,          ,               ,      。。  。。。


<?php
require('xajax.inc.php');
$xajax = new xajax;
$xajax->registerFunction("check");
function check($data)
{
        $response = new xajaxResponse();
        if (strlen($data['username'])<3)
        {
                $response->addAssign("info","innerHTML","       ");
                return $response->getxml();
        }
        else if(strlen(($data['username']))>20)
        {
                $response->addAssign("info","innerHTML","       ");
                return $response->getxml();
        }
        else
        {
                $response->addAssign("info","innerHTML","       ");
                return $response->getxml();
        }
}
$xajax->processRequests();
$xajax->printJavascript();
?>
<script language="javascript">
        function chkform()
        {
                xajax_check(xajax.getFormValues('form1'));
        }
</script>
<form id="form1" name="form1" action="?" method="post">
username:<input type="text" id="username" name="username"><div id="info" name="info"></div>
password:<input type="text" id="password" name="password" onclick="chkform();">
</form>
         


CODE:[Copy to clipboard]<?php
require('xajax.inc.php');
$xajax = new xajax;
function userisexist($username)
{
        $conn=@mysql_connect('localhost','root','root');
        if (!$conn){die(mysql_errorno());}
        $selectdb=@mysql_select_db('phpwind');
        if (!$selectdb){die(mysql_errorno());}
        $sql="select username from pw_members where username='".$username."'";
        $result=mysql_query($sql);
        $rs=mysql_num_rows($result);
        if ($rs==true)
        {
                return true;
        }
        else
        {
                return false;
        }
}

function checkuser($username)
{
        $response = new xajaxResponse();
        if (userisexist($username)==true)
        {
                $response->addAssign("showmsg","innerHTML","   ,".$username."    ");
                return $response->getxml();
        }
        else
        {
                $response->addAssign("showmsg","innerHTML","  ,".$username."    ");
                return $response->getxml();
        }
}
$xajax->registerFunction('checkuser');
$xajax->processRequests();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
        <head>
                <?php $xajax->printJavascript(); ?>
        <script language="javascript">
                        function checkform()
                        {
                                xajax_checkuser(document.getElementById('username').value);
                        }
                </script>
        </head>
        <body>
                <form action="?" id="form1" name="form1">
                <input type="input" id="username" name="username"><div id="showmsg" name="showmsg"></div>
                <input type="button" id="checkbt" name="checkbt" onclick="checkform();" value="Check Now">
                </form>
        </body>
</html>
  xajax          。
     xajax 0.2
check.php


CODE:[Copy to clipboard]<?php
require('reg.common.php');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
    <head>
        <?php $xajax->printJavascript(); ?>
        <script language="javascript">
            function checkform()
            {
                xajax_checkreg(document.getElementById('username').value);
            }
        </script>
    </head>
    <body>
        <form action="?" id="form1" name="form1">
        <input type="input" id="username" name="username"><div id="showmsg" name="showmsg"></div>
        <input type="button" id="checkbt" name="checkbt" onclick="checkform();" value="Check Now">
        </form>
    </body>
</html>
reg.common.php


CODE:[Copy to clipboard]<?php
define ('XAJAX_DEFAULT_CHAR_ENCODING','gb2312');
require('xajax.inc.php');
$xajax = new xajax('reg.server.php');
$xajax->registerFunction("checkreg");
?>
reg.server.php


CODE:[Copy to clipboard]<?php
require_once('reg.common.php');
function userisexist($username)
{
        $conn=@mysql_connect('localhost','root','root');
    if (!$conn){die(mysql_errorno());}
    $selectdb=@mysql_select_db('phpwind');
    if (!$selectdb){die(mysql_errorno());}
    $sql="select username from pw_members where username='".$username."'";
    $result=mysql_query($sql);
    $rs=mysql_num_rows($result);
    if ($rs==true)
    {
        return true;
    }
    else
    {
        return false;
    }
}

function isvalidname($username)
{
        $badkey=array("\\",'|','',' ',"'",'"','/','*',',','~',';','<','>','$',"\r","\t","
"); foreach($badkey as $value) { if (strpos($username,$value)!==false) { return false; exit; } } return true; } function checkreg($username) { $response = new xajaxResponse(); if (strlen($username)<3||strlen($username)>20) { $response->addClear('showmsg',"innerHTML"); $response->addAlert(' , !'); } elseif(isvalidname($username)==false) { $response->addClear('showmsg',"innerHTML"); $response->addAlert(' , !'); } else { if(userisexist($username)==true) { $response->addAssign('showmsg',"innerHTML"," , ".$username." !"); } else { $response->addAssign('showmsg',"innerHTML"," , ".$username." !"); } } return $response; } $xajax->processRequests(); ?>

좋은 웹페이지 즐겨찾기