简体   繁体   中英

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. 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. But I am getting an internal server 500 error at that line. 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. 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).

Try doing var_dump($_REQUEST); die(); var_dump($_REQUEST); die(); as the first line in signup.php. Does that give you a 200 status code? 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.


You have the question tagged with jQuery, but I don't see any jQuery in your code sample. 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.');
        },
    });
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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