//删除确定按钮
<a href="delete.php" onclick="return confirm('确定删除?');">删除</a>
1.不刷新页面
登录页面<body>
<h1>登录</h1> <div>用户名:<input type="text" id="uid" /></div> <div>密码:<input type="text" id="pwd" /></div> <div><input type="button" value="登录" id="btn"></div> </body> <script type="text/javascript"> $(document).ready(function(e){ $("#btn").click(function{ var uid = $("#uid").val(); var pwd = $("#pwd").val(); $.ajax({ url:"chuli.php", //处理页面的路径 data:{u:uid,p:pwd}, //传递的数据 type:"POST", //数据的提交传递方式 datatype:"TEXT", //返回值的类型,TEXT JSON XML三种类型可选 success:function(data){ if(data=="OK")
{
window.location = "Main.php"; //跳转到主页面
}
else
{
alert(data);
}
});
})
});
</script>
chuli.php
<?php //不要有空 顶到头写 $uid = $_POST["u"]; //接收 $pwd = $_POST["p"]; include "DBDA.php"; $db = new DBDA(); $sql = "select count(*) from login where username='{$uid}' and password='{$pwd}'"; $attr = $db->Query($sql); if($attr[0][0]==0) { echo "用户名密码不正确"; } else { echo "OK"; }