我通过使用ajax将数据发送到php文件并在php文件中检查它们。但是ajax并没有发布数据。下面的Ajax代码
$('button#submit').click(function () {
$.post($('#login-form').attr('action'),
$('#login-form :input').serializeArray(),
function(data){
if(data == "Ok")
{
window.location.href = data;
}
else
{alert(data.d);}
});
$('#login-form').submit(function(){
return false;
});
});
表格部分
<form action="giriskontrol.php" method="post" id="login-form">
<div id="rgesc-admin-container">
<input type="text" class="rgesc-kadi" name="admin-kadi" id="kadi"/>
<input type="password" class="rgesc-pass" name="admin-pass" id="kpass"/>
<button id="submit" class="rgesc-login"> </button>
</div>
</form>
Php part
<?php
include ("../config.php");
$kadi = mysql_real_escape_string($_POST["admin-kadi"]);
$pass = mysql_real_escape_string($_POST["admin-pass"]);
$cryptedPass= sha1($pass);
if(empty($kadi) || empty($pass)){
echo "Boş Alan Bırakmayın!"; }
else{
$sql = "SELECT count(*) FROM table WHERE username='$kadi' AND password='$cryptedPass'";
$res = mysql_query($sql);
$row = mysql_fetch_array($res);
if($row[0] > 0)
{
$sql = "SELECT * FROM table WHERE username='$kadi' AND password='$cryptedPass'";
$res = mysql_query($sql);
$get = mysql_fetch_array($res);
$_SESSION['admin'] = $get['username'];
$_SESSION['adminid'] = $get['id'];
echo "url";
}
else
{
echo "Böyle bir kayıt bulunmamaktadır!.";
}
} ?&GT;
在头标记之间包含<script type="text/javascript" src="js/jquery-1.8.2.min.js"></script>
。当我通过usinf firebug控制台输入ajax部件时,它可以工作。但是不能在头标签之间工作。