<!-- 报名查询填写信息 -->
<form action="{:U('Home/Index/baomingXinxi')}" class="from" method="post" id="from">
<p class="fix">
<label class="word word1"></label>
<input type="text" class="text" name="name" id="name">
</p>
<p class="fix">
<label class="word word4"></label>
<input type="text" class="text" name="mobile" id="mobile">
</p>
</form>
<!-- 按钮 -->
<div class="butBox fix">
<a href="javascript:;" class="butLeft" id="btn"></a>
<a href="{:U('Home/Index/baomingFrom')}" class="butRight"></a>
</div>
//js验证部分
$('#btn').click(function(){
var name =$.trim($("#name").val());
var mobile =$.trim($("#mobile").val());
if(name == ''){
$('#errorNotice').html("姓名不能为空");
$('.ly_mask').removeClass('none');
}else if(mobile == ''){
$('#errorNotice').html("联系电话不能为空");
$('.ly_mask').removeClass('none');
}else{
$.post("{:U('Home/Index/baomingChaxun')}",{name:name,mobile:mobile},function(data){
if(data.status==1){
$('#from').submit();
}else{
$('#errorNotice').html("用户信息不存在");
$('.ly_mask').removeClass('none');
}
})
}
});
//php处理
function baomingChaxun(){
$UserModel = M('user');
if(isset($_POST['name'])&&isset($_POST['mobile'])) {
$where['name'] = I('post.name');
$where['mobile'] = I('post.mobile');
$count = $UserModel->where($where)->count();
if($count>0){
$this->success();
}else{
$this->error();
}
}else{
$this->display();
}
}
function yanz(){
if(IS_AJAX){
}
}
function baomingXinxi(){
$UserModel = M('user');
if(isset($_POST['name'])&&isset($_POST['mobile'])) {
$where['name'] = I('post.name');
$where['mobile'] = I('post.mobile');
$user_info = $UserModel->where($where)->find();
$this->assign('data',$user_info);
$this->display();
}
}
php 输入用户名和联系电话 查找用户数据
最新推荐文章于 2021-04-06 06:27:35 发布