PHP+jquery+ajax
index.html
=============================================================================
=============================================================================
tjr_ajax.php
=============================================================================
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>推荐赠送</title>
<script type="text/javascript" src="jquery-1.2.6.pack.js.js"></script>
<script language="javascript">
$(document).ready(function(){
$("#tjrid").blur(function(){
var Mobile = /^((\(\d{3}\))|(\d{3}\-))?13\d{9}|15[0-9]\d{8}|18[0-9]\d{8}$/;
var tjrPhone = $.trim($("#tjrid").val());
if(tjrPhone==null || "" == tjrPhone){
$("#ts_tjr").html("<font color='green'>该项为可选项,可以不填写....</font>");
}else if(!Mobile.test(tjrPhone)){
$("#ts_tjr").html("<font color='red'>请输入号码,必须是手机号码....</font>");
}else{
$.ajax({
type:"POST",
url:"tjr_ajax.php",
data:"phone="+tjrPhone+"&page=1",
beforeSend:function(){},
success:function(msg)
{
if(msg=="success"){
$("#ts_tjr").html("<font color='green'>推荐人信息正确....</font>");
}else{
$("#tjrid").focus();
$("#ts_tjr").html("<font color='red'>该用户不是嗨客用户,请重新输入....</font>");
}
},
error:function()
{
$("#tjrid").focus();
$("#ts_tjr").html("<span><font color='red'>验证失败...</font></span>");
}
});
}
});
$("#userid").blur(function(){
var Mobile = /^((\(\d{3}\))|(\d{3}\-))?13\d{9}|15[0-9]\d{8}|18[0-9]\d{8}$/;
var usePhone = $.trim($("#userid").val());
if(usePhone==null || "" == usePhone){
$("#ts_use").html("<font color='red'>请输入用户手机号码....</font>");
$("#userid").focus();
}else if(!Mobile.test(usePhone)){
$("#ts_use").html("<font color='red'>请输入正确的用户号码,必须是手机号码....</font>");
$("#userid").focus();
}else{
$.ajax({
type:"GET",
url:"tjr_ajax.php",
data:"phone="+usePhone+"&page=2",
success:function(msg)
{
if(msg=="success"){
$("#ts_use").html("<font color='green'>该号码可用....</font>");
}else{
$("#userid").focus();
$("#ts_use").html("<font color='red'>该号码已经是嗨客用户,请重新输入....</font>");
}
},
error:function()
{
$("#userid").focus();
$("#ts_use").html("<span><font color='red'>验证失败...</font></span>");
}
});
}
});
});
function checkForm(obj)
{
var Mobile = /^((\(\d{3}\))|(\d{3}\-))?13\d{9}|15[0-9]\d{8}|18[0-9]\d{8}$/
if(document.getElementById('tjrid').value!='' && !Mobile.test(document.getElementById('tjrid').value)){
alert('请输入正确的推荐人号码,必须是手机号!');
obj.disable=false;
return false;
}else if(document.getElementById('userid').value==''){
alert('用户号码不能为空!');
obj.disable=false;
return false;
}else if(!Mobile.test(document.getElementById('userid').value)){
alert('请输入正确的用户号,必须是手机号码!');
obj.disable=false;
return false;
}
document.all.form1.submit();
return true;
}
</script>
<style type="text/css">
<!--
*{font-size:12px;}
-->
</style>
</head>
<body>
<center>
<form action="reship.php" method = "post" name="form1" onsubmit="return checkForm(this);">
<table width="900" height="141" border="1">
<tr>
<td colspan="4">用户推荐注册信息:</td>
</tr>
<tr>
<td width="295" height="19"> </td>
<td width="95">推荐人号码:</td>
<td width="120" align="left"><input type="text" name="trjPhone" id="tjrid" value="" size="15"/></td>
<td width="362" align="left"><span id="ts_tjr"> </span></td>
</tr>
<tr>
<td height="19"> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td>用户手机号:</td>
<td align="left"><input type="text" name="userPhone" id="userid" value="" size="15"/><span style="color:#F00">*</span></td>
<td align="left"><span id="ts_use"> </span></td>
</tr>
<tr>
<td height="19"> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td height="19"> </td>
<td align="center"><input type="submit" value="提交" id="submit" onclick=""/></td>
<td align="center"><input type="reset" value="取消"/></td>
<td> </td>
</tr>
</table>
</form>
</center>
</body>
</html>
=============================================================================
tjr_ajax.php
<?php
require_once('include/conn.php');
header("Cache-Control: no-cache");
$phone= $_REQUEST['phone'];
$page = $_REQUEST['page'];
$num = 0;
$sql = "select * from tb_user where usermobile='$phone'";
$query = mssql_query($sql);
$n = mssql_num_rows($query);
if($page == 1 && $n > 0){
$num = 1;
}
if($page == 2 && $n == 0){
$num = 1;
}
if($num==1){
echo "success";
}else{
echo "error";
}
?>
有兴趣的朋友可以研究下, 有不懂的可以留言我 QQ:513900855
...全文
相关推荐
php+jquery+ajax上传头像插件
用PHP JQUERY并使用了jcrop,uploadfiy制作的头像上传插件。有图片裁剪,图片尺寸过大时自动改变大小等功能.
使用jQuery Ajax进行PHP数据交互
通过使用jQuery的Ajax功能,我们可以轻松地在网页上使用PHP进行数据交互。希望本文对你有所帮助!现在,让我们编写一段JavaScript代码,使用jQuery Ajax来处理表单的提交事件,并将数据发送到PHP后端。最后,我们需要创建一个PHP后端处理程序(process.php),用于接收并处理从前端发送的数据。接下来,我们将创建一个简单的HTML表单,用户可以在其中输入数据并将其发送到PHP后端进行处理。函数的选项中,我们指定了PHP后端处理程序的URL、请求的类型为POST,并将数据设置为。
php 接收jQuery通过Ajax上传图片
1.upload.html <html> <head> <meta charset="utf-8"> <script src="jquery.min.js"></script> </head> <style> /*.thumb-image{*/ /*width:200px;*/ ...
jquery+ajax+php文件下载.rar
jquery+ajax+php文件下载,
PHP+jQuery+Ajax无刷新分页加搜索
PHP+jQuery+Ajax无刷新分页加搜索


基础编程
