When I was working on localhost,all my 9 pages were making ajax requests without any error. but when I uploaded the website to a server, ajax in all pages worked without any error in all pages but the login page! When I try to login it gives me the error
GET http://www.example.com/ajax/login.php?email=admin@me.com&password=1291995 500 (Internal Server Error)
here is the login code that I use in my website
function login(){
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
if(xmlhttp.responseText=="")
{document.getElementById("errorInLogin").style.display="block";
console.log(xmlhttp.responseText);}
else{
window.open("profile.php?id="+xmlhttp.responseText,"_self");
}
}
}
xmlhttp.open("GET", "ajax/login.php?email=" + document.getElementById("email").value + "&password=" + document.getElementById("password").value, true);
xmlhttp.send();
}
and this is my login php file code
require_once ('../functions/DataBaseConnection.php');
if (mysqli_real_escape_string($con,empty($_GET['email']))||empty(mysqli_real_escape_string($con,$_GET['password'])))
{echo "";die("");}
else
{
$email=mysqli_real_escape_string($con,$_GET['email']);
$p=mysqli_real_escape_string($con,$_GET['password']);
$sql = "SELECT `userid`, `email`,`password` FROM `user` WHERE email='$email'";
$userQuery=$con->query($sql) or die(mysqli_($con));
if($user=mysqli_fetch_array($userQuery))
{
$uid=$user['userid'];
$pass=$user['password'];
if(md5($p)==$pass)
{
session_start();
$_SESSION['userid'] = $uid;
echo $uid;
die("");
}
else
{
echo "";die("");}
}
else
{echo "";die("");}
}
Is there any thing with my code that would cause this error? The weird thing that Ajax works in all my files but this file, What could be wrong? and how can I fix it?