I have a login system hat uses ajax and php. The form checks are done using javascript then the form data sent to php to checked against the data base. The php will return 1 if the user is not in the database. I have done this before and it has worked fine but here, 'NOTHING'.
JQuery version:
<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
AJAX:
var pass = $('#pass').val();
var user = $('#user').val();
$.ajax({
url: 'func/check-login.php',
type: 'POST',
data:{user:user,pass:pass},
complete: function(e){
alert(parseInt(e));
if(e === 1){
$('#main_error').html('That username password combination is incorrect');
}else{
alert('Log user in');
}
}
});
PHP:
<?php
include '../DB.func/connect.php';
if(!empty($_POST)){
$_POST['user'] = mysql_real_escape_string($_POST['user']);
$_POST['pass'] = mysql_real_escape_string($_POST['pass']);
$username = $_POST['user'];
$password = $_POST['pass'];
if($username == ''){$user_err = 'You must insert tour username';}
if($password == ''){$pass_err = 'You must insert your passowrd';}
$query = mysql_query("SELECT * FROM user_admin WHERE user_name = '$username' OR email = '$username' AND password = '".md5($password)."'")or die(mysql_error());
if(mysql_num_rows != 0){
//login
echo '0';
}else{
echo 1;
}
}else{
echo '1';
}
?>
The alert in the complete function of the Ajax isn't opening with anything.