weixin_33693070 2009-11-14 12:18 采纳率: 0%
浏览 35

使用httpRequest进行ajax登录?

I am trying to develop my login script to give feedback to the user if the login is valid or not. Basically if it isn't correct a div box will show saying its wrong, if its correct it will show its valid and re-direct to a members page.

Would this be secure sending it to a php script..checking with the database, then the php script either returns a true or false value?

Something like this?

function check_login(username, password)
{
var httpRequest;
make_request()
function stateck() 
{


    if(httpxml.readyState==4)

    { 
        if (httpxml.responseText.indexOf("true") >= 0)
        {
        $("#valid_div").show();
        $("#invalid_div").hide();

        }
        else 
        {
        $("#invalid_div").show();
        $("#valid_div").hide();

        }


    }
    }

httpxml.onreadystatechange=stateck;
login_url="login/login.php?username=" + username.value + "password=" + password.value;
httpxml.open("GET",login_url,true);
httpxml.send(null);
}

I am planning to add an ssl certificate, so I assume this would be secure?

Thanks

  • 写回答

4条回答 默认 最新

  • weixin_33722405 2009-11-14 12:23
    关注

    If the login_url you are using is over HTTPS then it is secure. But to further increase security you might consider sending the username and password with POST instead of concatenating them to the url with a GET request.

    var parameters = 'username=' + username.value + '&password=' + password.value;
    httpxml.onreadystatechange = stateck;
    httpxml.open('POST', 'login/login.php', true);
    httpxml.setRequestHeader('Content-Type', "application/x-www-form-urlencoded");
    httpxml.setRequestHeader('Content-Length', parameters.length);
    httpxml.send(parameters);
    
    评论

报告相同问题?

悬赏问题

  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?