Моя кнопка регистрации не может быть отправлена, но в PHP + AJAX все в порядке - PullRequest
0 голосов
/ 08 октября 2019

У меня проблема с моей страницей регистрации на PHP и AJAX, кажется, что раздел входа в систему работает нормально, потому что я могу войти, но на кнопке регистрации выглядит отключенной или мертвой, не могу отправить форму. Я думаю, что я ошибаюсь в какой-то части, поэтому не могу понять, где может быть проблема.

Логин: это код входа в систему, который можно отправить в разделе входа в систему.

    <div class="form-group">
 <div class="col-sm-offset-3 col-sm-9">
 <button type="button" class="btn btn-block btn-primary" id="loginBtn">Sign In </button>
     </div>
      </div> 


        <?php require_once("inc/jscript_section.php"); ?>
        <script type="text/javascript">
        document.getElementById("loginBtn").addEventListener("click", submitLogin);
            function submitLogin(){
                var username = password = '';

                username = document.getElementById("usern").value;
                password = document.getElementById("pswd").value;

                if ((username === '' || password === '')){
                    window.location.assign("sign-in.php?m="+'None of the Fields must be empty!');
                } else{
                    if (window.XMLHttpRequest) {
                        // code for IE7+, Firefox, Chrome, Opera, Safari
                        xmlhttp = new XMLHttpRequest();
                    } else {
                        // code for IE6, IE5
                        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
                    }
                    xmlhttp.onreadystatechange = function() {
                        if (this.readyState == 4 && this.status == 200) {
                            if (this.responseText === '1'){
                                window.location.assign("dashboard/index.php");                              
                            }else{
                                window.location.assign("sign-in.php?m="+'Login Failed!');
                            }

                        }
                    };

                    xmlhttp.open("POST","dashboard/ajax/submitlogin.php",true);
                    xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
                    xmlhttp.send("password="+password+"&username="+username);
                    document.getElementById("loginBtn").disabled = true;
                }
            }
            </script>


Регистрация: это код регистрациикоторые не представляют, но выглядят отключенными или имеют неработающую ссылку.

<div class="form-group">
<div class="col-sm-offset-3 col-sm-9">
<button type="submit" class="btn btn-block btn-primary" id="regBtn">Sign Up</button>
 </div>
</div>



<?php require_once("inc/jscript_section.php"); ?>
        <script type="text/javascript">
        document.getElementById("regBtn").addEventListener("click", submitReg);
            function submitReg(){
                var fname = sname = othername = email = phoneno = refid = '';

                fname = document.getElementById("fname").value;
                sname = document.getElementById("sname").value;
                othername = document.getElementById("othername").value;
                email = document.getElementById("email").value;
                phoneno = document.getElementById("phoneno").value;
                refid = document.getElementById("refid").value;
                terms = document.getElementById("terms").checked;

                if ((fname === '' || sname === '' || email === '' || phoneno === '' || refid === '' || terms === false)){
                    console.log("No Field should be empty!");
                } else{
                    if (window.XMLHttpRequest) {
                        // code for IE7+, Firefox, Chrome, Opera, Safari
                        xmlhttp = new XMLHttpRequest();
                    } else {
                        // code for IE6, IE5
                        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
                    }
                    xmlhttp.onreadystatechange = function() {
                        if (this.readyState == 4 && this.status == 200) {

                            //window.location.assign("sign-up.php?m="+ this.responseText);
                            if (this.responseText == '1'){
                                document.getElementById("regResult").innerHTML = "Your registration was successful, check your email to complete the process";                              
                            }else{
                                document.getElementById("regResult").innerHTML = this.responseText;
                            }

                        }
                    };

                    xmlhttp.open("POST","dashboard/ajax/submitreg.php",true);
                    xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
                    xmlhttp.send("fname="+fname+"&sname="+sname+"&othername="+othername+"&phoneno="+phoneno+"&email="+email+"&refid="+refid);
                    document.getElementById("regBtn").disabled = true;
                }
            }
            </script>

1 Ответ

0 голосов
/ 08 октября 2019

я смог добавить разрешение в document.getElementById ("regBtn"). Enable = true;





<?php require_once("inc/jscript_section.php"); ?>
        <script type="text/javascript">
        document.getElementById("regBtn").addEventListener("click", submitReg);
            function submitReg(){
                var fname = sname = othername = email = phoneno = refid = '';

                fname = document.getElementById("fname").value;
                sname = document.getElementById("sname").value;
                othername = document.getElementById("othername").value;
                email = document.getElementById("email").value;
                phoneno = document.getElementById("phoneno").value;
                refid = document.getElementById("refid").value;
                terms = document.getElementById("terms").checked;

                if ((fname === '' || sname === '' || email === '' || phoneno === '' || refid === '' || terms === false)){
                    console.log("No Field should be empty!");
                } else{
                    if (window.XMLHttpRequest) {
                        // code for IE7+, Firefox, Chrome, Opera, Safari
                        xmlhttp = new XMLHttpRequest();
                    } else {
                        // code for IE6, IE5
                        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
                    }
                    xmlhttp.onreadystatechange = function() {
                        if (this.readyState == 4 && this.status == 200) {

                            //window.location.assign("sign-up.php?m="+ this.responseText);
                            if (this.responseText == '1'){
                                document.getElementById("regResult").innerHTML = "Your registration was successful, check your email to complete the process";                              
                            }else{
                                document.getElementById("regResult").innerHTML = this.responseText;
                            }

                        }
                    };

                    xmlhttp.open("POST","dashboard/ajax/submitreg.php",true);
                    xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
                    xmlhttp.send("fname="+fname+"&sname="+sname+"&othername="+othername+"&phoneno="+phoneno+"&email="+email+"&refid="+refid);
                    document.getElementById("regBtn").disabled = true;
                }
            }
            </script>
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...