ajax修改数据php ajax修改功能

php中,用到ajax更新数据,但是却不往数据库里面进看不懂你的代码~写得太烂
先用 url 传参单独执行一下 你的ajax 页面 。如果没有问题,在去检查你的js
PHP,ajax 双击修改input表单里面的数据,失去焦点,保存修改数据到数据库里面 。你想实现的就是php获取html中input的传值写入到数据库中
,你的PHP代码都没有 , 只有一个html文件,
php代码应该是用POST获取input的值,再执行sql 的insert into添加数据即可 。
求一个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="https://www.04ip.com/post/css/user_home.css"/
script src="/images/defaultpic.gif"/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="https://www.04ip.com/post/登录"/
/form
/div
/div
script
$('#btn').click(function(){
var str=$('#loginForm').serialize();
// alert(str);
$.ajax({
url:'',
dataType: "jsonp",
jsonpCallback: "callback",
type:'post',
data:str,
success:function(data){
if(data.status=='ok'){
alert(data.msg);
location.href="https://www.04ip.com/post/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($row0){
setcookie("tel",$phone,time()+24*3600);
echo 'callback({"status":"ok","msg":"登录成功","str":"'.$row.'"})';

推荐阅读