<html><head>
<meta charset="utf-8">
<script type="text/javascript" src="jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="a.js"></script>
<style type="text/css">
body { font:12px/1.6em "宋体" }
ul { list-style:none; }
li { margin-top:10px; }
</style>
</head>
<body>
<h3>会员登录</h3>
<div id="login">
<form method="post" action="login.php" id="form" name="form">
<ul>
<li>名字:<input type="text" name="user" id="user" size="16" maxlength="20"></li>
<li>密码:<input type="password" name="pass" id="pass" size="16" maxlength="20"></li>
<li>
<input type="submit" style="border:0" />
</li>
<li id="confirm"></li>
</ul>
</form>
</div>
</body></html>
$(document).ready(function(){
$("#form").submit(function(){
login();
return false;
});
});
function login(){
var user = $("#user").val();
var pass = $("#pass").val();
if (user == ""){
$("#confirm").text("请输入登录用户名");
$("#user").focus();
return false;
}
if(pass == ""){
$("#confirm").text("请输入登录密码");
$("#pass").focus();
return false;
}
$.ajax({
type: "POST",
url: "login.php",
data: "id=" + user + "&p=" + pass,
beforeSend: function(){
$("confirm").text("登录中,请稍候");
},
success: function(msg){
if(msg == "success"){
$("#confirm").text("登录成功,欢迎" + user + "回来!正在进入你的空间");
}else {
$("#confirm").text("没有此用户或者密码不正确!");
}
}
});
}
<?php
$p = isset($_POST["p"]) ? $_POST["p"] : $_GET["p"];
$id = isset($_POST["id"]) ? $_POST["id"] : $_GET["id"];
if($id == "admin" && $p == "admin"){
echo ‘success‘;
}
?>
时间: 2024-11-12 21:39:51