从数据库直接POST数据不会显示

时间:2018-02-07 07:21:02

标签: php

我很难把我的php webservices放在我的login.php的哪个位置,我使用$_POST作为$username$password来获取android的数据。当我测试我的PHP代码时,它会给我回复{"error":true,"error_msg":"Wrong credentials!"}。我相信我得到了这个错误,因为我没有插入数据。但我的问题是,当我尝试引导正确的数据时,它仍然给我相同的响应

Login.php

    <?php

    require_once 'Config.php';

    $response = array("error"=> FALSE);

    if(isset($_POST['USER_ID'])){




        $username = $_POST['USER_ID'];
        $password = $_POST['LASTNAME'];



        $pdo = Database::connect();
        $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

        $query = $pdo->prepare("SELECT * FROM tbl_UserDetails WHERE USER_ID = ? AND LASTNAME = ?");
        $query->execute(array($username,$password));

        $row = $query->fetch(PDO::FETCH_ASSOC);
        Database::disconnect();
    }
        if (!(empty($row))){

            $response["error"]= FALSE;
            $response["user"]["ID"]=$row["USER_ID"];
            $response["user"]["LASTNAME"]=$row["FIRSTNAME"];
            echo json_encode($response);    

        }
        else{
            $response["error"] = TRUE;
            $response["error_msg"] = "Wrong credentials!";
            echo json_encode($response);
        }





    ?>

我改变的时候:

    $username = $_POST['USER_ID'];
    $password = $_POST['LASTNAME'];

INTO

//01071997 and JOSH is correct data from my database
        $username = $_POST['01071997'];
        $password = $_POST['JOSH'];

它仍然给我回复:

{"error":true,"error_msg":"Wrong credentials!"}

我在上面做错了什么?

0 个答案:

没有答案