求一个PHP + Ajax 表单无刷新大批量修改数据的实例
展开全部
<!DOCTYPE HTML>
<html>
<head>
<title>微吧外卖</title>
<meta name="keywords"
content="JqueryMobile JqueryMobile进阶 JqueryMobile教程 Jquery mobile进阶 转屏效果的简单实现 Warren " />
<meta name="description" content="模拟JqueryMobile slide转屏效果的简单实现" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport"
content="user-scalable=no, width=device-width, initial-scale=1.0" />
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<link rel="stylesheet" href="css/user_home.css"/>
<script src="js/jquery-1.9.1.min.js"></script>
<style>
#scroller3{margin-top:2em;
margin-left: 1.3em;
font-size: 2em;
}
#scroller3 input{height: 3em;
width: 80%;
margin-top: 1.5em;
margin-left: 2em;
border-top: none;
border-left: none;
border-right: none;
border-bottom: 1px solid #ef7b14;}
#pwd{margin-top:2em;}
#btn{display: block;
font-weight: bold;
height: 3.6em;
border: none;
color: #fff;
background: #ef7b14;
margin-top: 2em;
border-radius: 0.3em;
}
.da{border: 1px solid #ef7b14;
width: 90%;
height: 9em;
border-radius: 0.3em;
}
.da span{padding-left:0.5em; }
</style>
</head>
<body>
<div id="page4" class="ui-mobile-viewport-transitioning ui-page hide">
<div class="header">
<h1>商家手机号登录</h1>
</div>
<h2 style="font-size: 3em;color: #ef7b14;margin: 1em">微吧欢迎您 :)</h2>
<div id="scroller3">
<form id="loginForm">
<div class="da">
<input type="text" value="" id="pwd" name="shop" placeholder="店铺名称"/><br/>
<input type="text" value="" name="name" id="name" placeholder="用户名"/><br/>
<input type="password" value="" id="pwd" name="pwd" placeholder="密码"/><br/>
</div>
<input type="button" id="btn" value="登录"/>
</form>
</div>
</div>
<script>
$('#btn').click(function(){
var str=$('#loginForm').serialize();
// alert(str);
$.ajax({
url:'http://api.wei8a.com/logindd.php',
dataType: "jsonp",
jsonpCallback: "callback",
type:'post',
data:str,
success:function(data){
if(data.status=='ok'){
alert(data.msg);
location.href="./home.html"
}else{
alert(data.msg);
}
},
error:function(error){
alert(error);
}
})
})
</script>
</body>
</html>
<?php
header('content-type:text/html;charset=utf-8');
$con=mysql_connect('连接数据库');
$dd=mysql_select_db('连接数据库名字');
mysql_query('set names utf8');
session_start();
$phone=$_GET["name"];
$pwd=$_GET["pwd"];
$shop=$_GET["shop"];
$selectSqlStr=mysql_query("select * from shopuser where shop='".$shop."'and tel='".$phone."' and pwd='".$pwd."'");
$row= mysql_num_rows($selectSqlStr);
$str= mysql_fetch_assoc($selectSqlStr);
if($row>0){
setcookie("tel",$phone,time()+24*3600);
echo 'callback({"status":"ok","msg":"登录成功","str":"'.$row.'"})';
}else{
echo 'callback({"status":"no","msg":"用户名与密码不符?","str":"'.$row.'"})';
echo $_SESSION["tel"];
}
mysql_close($con);
?>
<html>
<head>
<title>微吧外卖</title>
<meta name="keywords"
content="JqueryMobile JqueryMobile进阶 JqueryMobile教程 Jquery mobile进阶 转屏效果的简单实现 Warren " />
<meta name="description" content="模拟JqueryMobile slide转屏效果的简单实现" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport"
content="user-scalable=no, width=device-width, initial-scale=1.0" />
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<link rel="stylesheet" href="css/user_home.css"/>
<script src="js/jquery-1.9.1.min.js"></script>
<style>
#scroller3{margin-top:2em;
margin-left: 1.3em;
font-size: 2em;
}
#scroller3 input{height: 3em;
width: 80%;
margin-top: 1.5em;
margin-left: 2em;
border-top: none;
border-left: none;
border-right: none;
border-bottom: 1px solid #ef7b14;}
#pwd{margin-top:2em;}
#btn{display: block;
font-weight: bold;
height: 3.6em;
border: none;
color: #fff;
background: #ef7b14;
margin-top: 2em;
border-radius: 0.3em;
}
.da{border: 1px solid #ef7b14;
width: 90%;
height: 9em;
border-radius: 0.3em;
}
.da span{padding-left:0.5em; }
</style>
</head>
<body>
<div id="page4" class="ui-mobile-viewport-transitioning ui-page hide">
<div class="header">
<h1>商家手机号登录</h1>
</div>
<h2 style="font-size: 3em;color: #ef7b14;margin: 1em">微吧欢迎您 :)</h2>
<div id="scroller3">
<form id="loginForm">
<div class="da">
<input type="text" value="" id="pwd" name="shop" placeholder="店铺名称"/><br/>
<input type="text" value="" name="name" id="name" placeholder="用户名"/><br/>
<input type="password" value="" id="pwd" name="pwd" placeholder="密码"/><br/>
</div>
<input type="button" id="btn" value="登录"/>
</form>
</div>
</div>
<script>
$('#btn').click(function(){
var str=$('#loginForm').serialize();
// alert(str);
$.ajax({
url:'http://api.wei8a.com/logindd.php',
dataType: "jsonp",
jsonpCallback: "callback",
type:'post',
data:str,
success:function(data){
if(data.status=='ok'){
alert(data.msg);
location.href="./home.html"
}else{
alert(data.msg);
}
},
error:function(error){
alert(error);
}
})
})
</script>
</body>
</html>
<?php
header('content-type:text/html;charset=utf-8');
$con=mysql_connect('连接数据库');
$dd=mysql_select_db('连接数据库名字');
mysql_query('set names utf8');
session_start();
$phone=$_GET["name"];
$pwd=$_GET["pwd"];
$shop=$_GET["shop"];
$selectSqlStr=mysql_query("select * from shopuser where shop='".$shop."'and tel='".$phone."' and pwd='".$pwd."'");
$row= mysql_num_rows($selectSqlStr);
$str= mysql_fetch_assoc($selectSqlStr);
if($row>0){
setcookie("tel",$phone,time()+24*3600);
echo 'callback({"status":"ok","msg":"登录成功","str":"'.$row.'"})';
}else{
echo 'callback({"status":"no","msg":"用户名与密码不符?","str":"'.$row.'"})';
echo $_SESSION["tel"];
}
mysql_close($con);
?>
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
用jquery的ajax写,jquery手册里有例子
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询