ช่วยดูให้ทีนะค่ะ มันไม่ส่งค่าตัวแปรไปอะค่ะ
ถ้าเป็นในIEใช้ได้ค่ะ แต่พอให้firefoxกะchromeพอกดenterปุ๊บ มันก็อยู่หน้าเดิมค่ะ ทั้งๆที่ตรงurlก็มีค่าปรากฎนะค่ะ
ขอให้พี่ๆช่วยดูให้หน่อยนะค่ะ
index.php
<?php
/*** http://xxxxxxxx/admin/index.php ***/
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html" charset="utf-8" >
<title>.: Administrator Login :.</title>
<style type="text/css">
body {font-family:Microsoft Sans Serif, Arial, CordiaUPC; font-size:13px;}
td {font-family:Microsoft Sans Serif, Arial, CordiaUPC; font-size:13px;}
hr.footer {color:#CC0000; width:700; text-align:left;}
a.cate {text-decoration:none; color:#FFFFFF;}
a.cate:hover {color:#2E8B57;}
</style>
<script type="text/javascript" src="js/jquery-1.4.2.js"></script>
<script language="JavaScript">
$(function login(){
$('input#btnLogin').submit(function login(){
//alert("b");
$.post("/admin/AjaxPHPLoginForm2.php", $("#frmMain").serialize(), function login(data){
if( data == "Y" ){
window.location = 'http://xxxxxxxxx/admin/insertuser_form.php';
}else{
//alert("a")
$('div#mySpan').html(data);
}
});
});
});
</script>
</head>
<body>
<!--Start Login Form-->
<form name="frmMain" id="frmMain"><br>
<table align="center">
<tr>
<td bgcolor="#2E8B57" colspan="2" align="center" height="30">
<font color="#FFFFFF"><b>.: Administrator Login :. </b></font>
</td>
</tr>
<tr bgcolor="#CAF9CA" >
<td align="right">
<b>ชื่อผู้ใช้ :</b>
</td>
<td>
<input type="text" name="txtUsername" id="txtUsername" size="20" />
</td>
</tr>
<tr bgcolor="#CAF9CA" >
<td align="right">
<b>รหัสผ่าน :</b>
</td>
<td>
<input type="password" name="txtPassword" id="txtPassword" size="20" /></th>
</td>
</tr>
<tr>
<td colspan="2" align="center">
<input type="submit" name="btnLogin" id="btnLogin" value="Login" />
</td>
</tr>
</table>
<!--End Login Form-->
<div id="mySpan"></div>
</form>
</body>
</html>
AjaxPHPLoginForm2.php
<?php
session_start();
$strUsername = trim($_POST["txtUsername"]);
$strPassword = trim($_POST["txtPassword"]);
//*** Check Username ***//
if(trim($strUsername) == "")
{
echo "<br><center><font color=red>** Plase input [Username] **</font></center>";
exit();
}
//*** Check Password ***//
if(trim($strPassword) == "")
{
echo "<br><center><font color=red>** Plase input [Password] **</font></center>";
exit();
}
if(trim($strUsername) == "admin" && trim($strPassword) == "12345")
{
//*** Session ***//
$_SESSION["username"] = $strUsername;
session_write_close();
echo "Y";
}
else
{
echo "<br><center><font color=red>** Username or Password is wrong **</font></center>";
}
//mysql_close($objConnect);
?>
$('input#btnLogin').submit(function login(){
เป็น $('#btnLogin').submit(function login(){ ดูนะ