PHP MySQL更新信息

时间:2017-09-05 21:07:21

标签: php mysql

我找不到解决问题的方法。我需要更新MySQL数据库中的数据,但我的changePin.php无效。

这是我的changePin.php

<?php

require_once '../includes/DbOperations.php';
$response = array();

if($_SERVER['REQUEST_METHOD']=='PUT'){
    if(isset($_POST['cardno']) and isset($_POST['pin'])){
        $db = new DbOperations();
        if($db->changePin($_POST['cardno'], $_POST['pin'])){
            $response['error'] = false;
            $response['message'] = "Pin successfully change";
        }
        else{
            $response['error'] = true;
            $response['message'] = "Invalid Card Number or Pin";
        }
    }
    else{
        $response['error'] = true;
        $response['message'] = "Required fields are missing";
    }
}

echo json_encode($response);

当我尝试使用带有PUT的Postman构建器作为cardno和pin的方法和键时,它给了我

{"error":true,"message":"Required fields are missing"}

0 个答案:

没有答案