简体   繁体   English

用户注册注册错误

[英]User Register Sign up Error

I am making a website and I have a signup.php page where the users can register and enter their information into the mysqli database. 我正在建立一个网站,并且有一个signup.php页面,用户可以在其中注册并将其信息输入mysqli数据库。 When I do this, I am almost there, I just keep getting a problem at this one line: 当我这样做时,我快到了,我在这一行上一直遇到问题:

        ajax.send("&u="+u+"&e="+e+"&p="+p1+"&g="+g);

It is basically sending the variables in the ajax/javascript check to get ready for transport to server. 它基本上是在ajax / javascript检查中发送变量以准备好传输到服务器。 But I am getting an internal server 500 error at that line. 但是我在那条线上收到一个内部服务器500错误。 Any ideas? 有任何想法吗? I will post more code if you want me to. 如果您愿意,我将发布更多代码。

function ajaxReturn(x){
if(x.readyState == 4 && x.status == 200){
    return true;
}
}
function signup(){
var u = _("username").value;
var e = _("email").value;
var p1 = _("pass1").value;
var p2 = _("pass2").value;
var g = _("gender").value;
var status = _("status");
if(u == "" || e == "" || p1 == "" || p2 == "" || g == ""){
    status.innerHTML = "Fill out all of the form data";
} else if(p1 != p2){
    status.innerHTML = "Your password fields do not match";
}  else {
    _("signupbtn").style.display = "none";
    status.innerHTML = 'please wait ...';
    var ajax = ajaxObj("POST", "signup.php");
    ajax.onreadystatechange = function() {
        if(ajaxReturn(ajax) == true) {
            if(ajax.responseText != "signup_success"){
                status.innerHTML = ajax.responseText;
                _("signupbtn").style.display = "block";
            } else {
                window.scrollTo(0,0);
                _("signupform").innerHTML = "OK "+u+", check your   email inbox and junk mail box at <u>"+e+"</u> in a moment to complete the sign up process by activating your account. You will not be able to do anything on the site until you       successfully activate your account.";
            }
        }
    }
    type:post;
    ajax.send("&u="+u+"&e="+e+"&p="+p1+"&g="+g);
}

} }

A 500 Internal Server Error code is an HTTP response code, indicating that you have reached out to the server and it has responded with an error. 500 Internal Server Error代码是HTTP响应代码,表示您已与服务器联系,并且已响应错误。 So it doesn't appear to be a problem with your JS code (at least as far as we can tell from what you've posted). 因此,您的JS代码似乎没有问题(至少就我们发布的内容而言)。

Try doing var_dump($_REQUEST); die(); 尝试做var_dump($_REQUEST); die(); var_dump($_REQUEST); die(); as the first line in signup.php. 作为signup.php的第一行。 Does that give you a 200 status code? 这会给您200状态代码吗? If so, try moving that line down your code on the server until you get back to the 500 Internal Server Error, and you've found the line that's causing the problem. 如果是这样,请尝试将该行在服务器上的代码下移,直到回到500 Internal Server Error,然后找到导致问题的行。


You have the question tagged with jQuery, but I don't see any jQuery in your code sample. 您有用jQuery标记的问题,但我在代码示例中看不到任何jQuery。 If you do have it, try this: 如果有,请尝试以下操作:

function signup() {
    var status = $('#status');
    var signupbtn = $('#signupbtn');
    var data = {
        u: $('#username').val(),
        e: $('#email').val(),
        p: $('#pass1').val(),
        g: $('#gender').val()
    };

    if (data.u == '' || data.e == '' || data.p == '' || data.g == '') {
        status.text('Fill out all of the form data');
        return;
    } else if (data.p != $('#pass2').val()) {
        status.text('Your password fields do not match');
        return;
    }

    signupbtn.hide();
    status.text('please wait...');

    $.ajax({
        type: 'post',
        url: 'signup.php',
        data: data,
        success: function(responseText) {
            if (responseText != 'signup_success') {
                status.text(responseText);
                signupbtn.show();
                return;
            }

            window.scrollTo(0, 0);
            $('#signupform').html('OK '+ data.u +', check your email inbox and junk mail box at <u>'+ data.e +'</u> in a moment to complete the sign up process by activating your account. You will not be able to do anything on the site until you successfully activate your account.');
        },
    });
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM