PHP的ajax
2020-12-13 05:19
YPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
标签:style c code java http ext
代码如下
先建立一个表单
然后
数据库的基本语言
if(isset($_GET[‘user‘])){
$user = $_GET[‘user‘];
$conn = mysql_connect("localhost","root","") or
die("数据库连接失败".mysql_error());
mysql_select_db("test");
mysql_query("set names ‘utf8‘");
$sql = "select count(*) from bbs where userName=‘$user‘";
$result = mysql_query($sql);
$row = mysql_fetch_row($result);
if($row[0]){
echo "该用户名已经被注册";
}else{
echo
"该用户名还没有被使用过,可以注册";
}
}
?>
最后AJAX
var xmlHttp;
function getXmlHttp(){
if(window.ActiveXObject){
xmlHttp = new
ActiveXObject("MICROSOFT.XMLHTTP");
}else if(window.XMLHttpRequest){
xmlHttp = new XMLHttpRequest();
}
}
function sendParam(url){
getXmlHttp();
xmlHttp.open("GET","check.php?user="+url,true);
//
setRequestHeader("Content-Type","application/x-www-form-urlencoded");
xmlHttp.onreadystatechange = getTxt;
xmlHttp.send(null);
}
function
getTxt(){
if(xmlHttp.readyState == 4){
if(xmlHttp.status ==
200){
var sp = document.getElementById("tishi");
sp.innerHTML = xmlHttp.responseText;
}
}
}
PHP的ajax,搜素材,soscw.com
PHP的ajax
标签:style c code java http ext
原文地址:http://www.cnblogs.com/gx9401142810/p/3735644.html
上一篇:【基础】Java 8 中的常量池、字符串池、包装类对象池
下一篇:recover Windows 7 boot partition overwritten by Linux Mint boot loader