xajax 클래스
7326 단어 JavaScriptsqlmysqlPHPSQL Server
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();
?>
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
기초 정리 - 1문자 (String) 숫자 (Number) 불린 (Boolean) null undefined 심볼 (Symbol) 큰정수 (BigInt) 따옴표로 묶어 있어야 함 Not-A-Number - 숫자 데이터 / 숫자로 표...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.