dqitk20644 2015-07-06 16:41
浏览 76

使用ajax时PHP内部服务器错误

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?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
    • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
    • ¥15 手机接入宽带网线,如何释放宽带全部速度
    • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
    • ¥15 ETLCloud 处理json多层级问题
    • ¥15 matlab中使用gurobi时报错
    • ¥15 这个主板怎么能扩出一两个sata口
    • ¥15 不是,这到底错哪儿了😭
    • ¥15 2020长安杯与连接网探
    • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么