首页 > 解决方案 > 当我使用邮递员时没有找到结果

问题描述

我有一个连接到 mysql 数据库的 PHP 代码。我想从邮递员工具发送用户登录数据并在php代码中接收它然后将其返回结果

问题是发送数据时没有得到结果

PHP代码

<?php
$response = array();
header("Content-type: application/json; charset=utf-8");
mb_internal_encoding('UTF-8');
mb_http_output('UTF-8');
include 'db/db_connect.php';
include 'functions.php';

//Get the input request parameters
$inputJSON = file_get_contents('php://input');
$input = json_decode($inputJSON, TRUE); //convert JSON into array

//Check for Mandatory parameters
if(isset($input['username']) && isset($input['password']) ){
    $username = $input['username'];
    $password = $input['password'];
    $query    = "SELECT full_name , password_hash   , salt ,  email ,  id_con  , born , city  , country و card_id   ,cardstatus, cardvalue FROM member WHERE username = ?";

    if($stmt = $con->prepare($query)){
        $stmt->bind_param("s",$username);
        $stmt->execute();
        $stmt->bind_result($fullName , $passwordHashDB ,$salt, $email  , $countryid , $born , $city , $country  ,$cardid  ,$cardstatus, $cardvalue);
        if($stmt->fetch()){
            //Validate the password
            if(password_verify(concatPasswordWithSalt($password,$salt),$passwordHashDB)){

                $response["status"] = 0;
                $response["message"] = "Login successful";
                $response["full_name"] = $fullName;
                $response["card_id"] = $cardid;
                $response["email"] = $email;
                $response["id_con"] = $countryid;
                $response["country"] = $country;
                $response["city"] = $city;
                $response["born"] = $born;
                $response["cardstatus"] = $cardstatus;
                $response["cardvalue"] = $cardvalue;


            }
            else{
                $response["status"] = 1;
                $response["message"] = "Invalid username and password combination";
            }
        }
        else{
            $response["status"] = 1;
            $response["message"] = "Invalid username and password combination";
        }

        $stmt->close();
    }
}
else{
    $response["status"] = 2;
    $response["message"] = "Missing mandatory parameters";
}
//Display the JSON response
echo json_encode($response);
?>

截屏

在此处输入图像描述

标签: jsonrequestpostman

解决方案


推荐阅读