I know that there were as many related questions as this one. But I did not find a single question that could solve my problem, or I have not found it yet. Umm ... I use three types of browsers: Maxthon 4.4.2.2000, Spark Security Browser 33.9.2000.3033 and Mozilla 32.0.3.
I use $.ajax()to submit data from my login form
<form method="POST" id="login_data">
<table>
<tr>
<td>Username</td>
<td><input id="txt_user" type="text" name="txt_username"></td>
<td><label id="warn_username"></label></td>
</tr>
<tr>
<td>Password</td>
<td><input id="txt_password" type="password" name="txt_password"></td>
<td><label id="warn_password"></label></td>
</tr>
<tr>
<td colspan="1" />
<td><button name="login" id="lgn_button">Login</button></td>
</tr>
</table>
</form>
And my javascript looks like this:
$(document).ready(function(){
$('#lgn_button').click(function(){
var user = $('#txt_user').val();
var password = $('#txt_password').val();
if(user==""){
alert('');
}
else{
$.ajax({
url: 'login.php',
type: 'POST',
data: {username:user,password:password},
success:function(){
}
});
}
});
});
The last one is my php file, which is connected to the server for user authentication
<?php
session_start();
include '../controls/connection.php';
include '../controls/function.php';
shout($_POST['username']);
open_connection($dbserver,$dbuser,$dbpass,$dbname);
$query = mysql_query('SELECT COUNT(user_name) FROM Euser WHERE user_name="'.$_POST['username'].'"');
$count = mysql_fetch_row($query);
if($count[0]==0){
}
else{
$query = mysql_query('SELECT * FROM Euser WHERE user_name="'.$_POST['username'].'"');
$check=mysql_fetch_assoc($query);
if($check['user_password']==md5($_POST['password'])){
$_SESSION[md5('user')]=$_POST['username'];
$_SESSION[md5('author')]=$check['user_authority'];
}
}
?>
For this function:, open_connection()it works fine. The problem is that this code works fine in Maxthon browser, but not 2 others, why? Can anyone explain to me? I am newbie. Thanks so much for every answer, and I appreciate it.