显示错误用户凭据的模式

时间:2018-02-01 02:08:08

标签: javascript php html

我有两个页面,Login.phpLoginCheck.php。我正在验证LoginCheck.php中凭据的正确和错误方案。我想在不正确的凭据上显示Login.php中的模态。但是,我不知道该怎么做。

  1. 我尝试过警告,它只在控制台中显示消息
  2. 我在考虑如何将else的{​​{1}}重定向到LoginCheck.php的功能,Login.php显示所有其他模态,但不知道该怎么做< / LI>

    的login.php

    function openUserProfileModal ()
    {
        var modal = document.getElementById('modal');
        modal.style.display = "none";
    }
    
    function validateLogin()
    {
        var modal = document.getElementById('modal');
        var errorDescription = document.getElementById('errorDescription');
        var processing = document.getElementById('processingLogin');
        var Email = document.getElementById('Email').value;
        var pass = document.getElementById('Password').value;
    
        if(Email == "" && pass == "")
        {
            modal.style.display="block";
            errorDescription.innerHTML = "Please enter your email address and password";
        }
        else if (Email != "" && pass == "") 
        {
            modal.style.display="block";
            errorDescription.innerHTML = "Please enter your password";
        }
        else if (Email == "" && pass != "") 
        {
            modal.style.display="block";
            errorDescription.innerHTML = "Please enter your email address";
        }
        else if (Email == null && pass == null) 
        {
            modal.style.display="block";
            errorDescription.innerHTML = "Please enter your email address and password";
        }
        else
        {
    
            //processing.style.display = "block";
    
            // validation for correct and incorrect credentails
            ajax.sender_data_json_by_url_callback('LoginCheck.php', 
            {
                act: 'login',
                email: Email,                                       
                pass: pass
            });
            //this.check("LoginFornmDiv")
        }
    

    LoginCheck.php

    <?php
    ob_start();
    session_cache_expire();
    session_start();
    require_once("DBINTClass.php");
    require_once("EncryptionClass.php");
    
    
    
    if (isset($_REQUEST['act']) && $_REQUEST['act'] != '' && $_REQUEST['act'] != null && $_REQUEST['act'] == 'login') 
    {
    
            $dd = new DBINT;
    
           $un = $_REQUEST['email'];
           $pw = $_REQUEST['pass'];
           $Encryptor = new Encryption();
           $ep = $Encryptor->EncryptPassword($pw);
    
           $id = (int)$dd->GetLogID($un,$ep);
           if ($id > 0)
           {
            $ltid = (int)$dd->GetLogTypeID($id);
            $d1h = $dd->GetHeaderDetails($id,$ltid);
            list($logintypename,$orgid,$orgtypeid,$orgname,$deptid,$deptname,$teamid,$personid,$persontypename,$firstname,$lastname) = explode(";",$d1h);
    
            $_SESSION['uid'] = $id; //user loginid
            $_SESSION['tpid'] = $ltid; //login type id: 1-Org Admin; 7-School Admin; 2-Department Admin; 3-Team Admin; 6-Teacher; 5-User; 6-CI Admin;
            $_SESSION['Company'] = $orgname;//org-school name
            $_SESSION['Person'] = $lastname.' '.$firstname;
            $_SESSION['PersonType'] = $logintypename;//login type name
            $_SESSION['orgid'] = $orgid;
            $_SESSION['orgtypeid'] = $orgtypeid;//1-organisation; 2-school
            $_SESSION['deptid'] = $deptid;
            $_SESSION['teamid'] = $teamid;
            //start Alex 23/12/2017 change calling functions
            $_SESSION['dept_cnt'] = $dd->GetHeaderCountDepartment($ltid,$orgid,$deptid,$teamid);//number odf departments/classes
            $_SESSION['team_cnt'] = $dd->GetHeaderCountTeam($ltid,$orgid,$deptid,$teamid);//number of teams/teachers
            $_SESSION['staff_cnt'] = $dd->GetHeaderCountStaff($ltid,$orgid,$deptid,$teamid);//number of staff/student
            $_SESSION['language_cnt'] = $dd->GetHeaderCountLanguages($ltid,$orgid,$deptid,$teamid);//number of language spoken
            $_SESSION['belief_cnt'] = $dd->GetHeaderCountWorldViews($ltid,$orgid,$deptid,$teamid);//number of beliefs
            $_SESSION['country_cnt'] = $dd->GetHeaderCountCountries($ltid,$orgid,$deptid,$teamid);//number of countries
            //end Alex 23/12/2017 old functions ????
            $_SESSION['lhd'] = $d1h;
            //keyfacts guages calculations
            $ril = $dd->RICalculation($orgid,$deptid,$teamid,$ltid);
            list($ldli,$dli,$ldei,$dei,$ldwi,$dwi,$lrii,$rii) = explode(";",$ril);
            $_SESSION['de'] = $dei;
            $_SESSION['dl'] = $dli;
            $_SESSION['dw'] = $dwi;
            $_SESSION['ri'] = $rii;
            $_SESSION['lde'] = $ldei;
            $_SESSION['ldl'] = $ldli;
            $_SESSION['ldw'] = $ldwi;
            $_SESSION['lri'] = $lrii;
            $result = array("act" => "location", "Result" => "PanelAdmin.php");
                echo json_encode($result);
            }
            else
            {
    
                //Show modal in here somehow
            }
    }
    ?>
    

    请帮忙

1 个答案:

答案 0 :(得分:0)

感谢您的回复。我首先学习了AJAX,然后使用它,比如AJAX调用。将用户从Login.php发送到LoginCheck.php并使用AJAX在else语句中显示错误,如果这是有意义的。