Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/251.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 正在尝试使用localhost数据库验证电子邮件和密码_Php_Jquery Mobile_Authentication_Cordova - Fatal编程技术网

Php 正在尝试使用localhost数据库验证电子邮件和密码

Php 正在尝试使用localhost数据库验证电子邮件和密码,php,jquery-mobile,authentication,cordova,Php,Jquery Mobile,Authentication,Cordova,您好,我一直在尝试为我的phonegap移动应用程序创建身份验证登录,但是在我的web浏览器上进行测试时,当我在登录表单中输入电子邮件和密码的值(与存储在localhost数据库中的值完全相同)时,我总是收到一条警报,提示“您输入了错误的电子邮件和密码” 我强烈感觉到它与我的login.js文件有关 $(function(){ $('form').submit(function(){ if(validateEmail() && validateUserPassw

您好,我一直在尝试为我的phonegap移动应用程序创建身份验证登录,但是在我的web浏览器上进行测试时,当我在登录表单中输入电子邮件和密码的值(与存储在localhost数据库中的值完全相同)时,我总是收到一条警报,提示“您输入了错误的电子邮件和密码”

我强烈感觉到它与我的login.js文件有关

$(function(){
    $('form').submit(function(){

    if(validateEmail() && validateUserPassword())
    {
    $.post('libs/auth.php',$('form').serialize(),function(response){
    if(response == 'true')
    {
    alert('You Have logged in successfully');
    setTimeout(function(){
        $.mobile.changePage('index.php', { transition: "slide"});
        },2000);
    }
    else
    {
    alert('You have entered the wrong Email and Password');
    }
    });
    }

    validateEmail();
    function validateEmail(){
    if($('#email').val().length == 0)
    {
    alert('Email is empty');
    return false;
    }
    else
    {
    return true;
    }


    }
    validateUserPassword();
    function validateUserPassword(){
    if($('#password').val().length == 0)
    {
    alert('Password is empty');
    return false;
    }
    else
    {
    return true;
    }

    }



    })
})
为了防止这不是问题,我将包括各种其他相关代码:

Login.php中的登录按钮

<div id="loginButtonDiv" data-role="field-contain">
    <button name="login" type="submit" data-inline="true">Log-In</button>
    </div> <!-- End login button div -->

登录
数据库类(Class.Database.php)


class.manageUsers.php

<?php

    include_once( 'class.database.php' );


    class ManageUsers{
        protected $link;    
        function __construct(){

        $db_conn = new ManageDatabase;
        $this->link = $db_conn->connect();
        return $this->link;

}
function loginUsers($email,$password)
        {
        $query = $this->link->query("SELECT * FROM users WHERE email = '$email' AND password = '$password' LIMIT 1");
        $rowCount = $query->rowCount();
        return $rowCount;

        }
}

?>


如果您能帮助解决此问题,我们将不胜感激

可爱的脆弱。。。除了初始连接之外,DB代码只是假设在所有阶段都成功。这是一个糟糕的假设。有没有关于我将如何改进这一点的建议?
<?php

    include_once( 'class.database.php' );


    class ManageUsers{
        protected $link;    
        function __construct(){

        $db_conn = new ManageDatabase;
        $this->link = $db_conn->connect();
        return $this->link;

}
function loginUsers($email,$password)
        {
        $query = $this->link->query("SELECT * FROM users WHERE email = '$email' AND password = '$password' LIMIT 1");
        $rowCount = $query->rowCount();
        return $rowCount;

        }
}

?>
<?php
    if($_POST)
    {

    include_once( '../core/class.manageUsers.php' );

    $email = trim($_POST['email']);
    $password = trim($_POST['password']);

    if(empty($email) && empty($password))
    {
        echo 'All fields are required';
        }
        else{
            $password = md5($password);
            $init = new ManageUsers;
            $login = $init->loginUsers($email,$password);

            if($login == 1)
            {
            echo 'true';

            }
            else{
            echo 'invalid credentials';
            }
}
}


?>