rest — API бронирования в основном php не работает, потому что, когда я делаю бронирование через почтальона или http-запросчика, бронирование не появляется в таблице db?

Бронирование не добавляется в БД Снимок экрана с бронированием, которое не добавляется в БД и показывает сообщение с поздравлением в приложении почтальона.
Пустые записи в БД Снимок экрана с БД, который показывает пустые записи.
Booking.php: код файла бронирования.

 include_once('config.php');
if ( $_POST ) {
// Get data
$username = isset($_POST['username']) ? mysqli_real_escape_string($conn, $_POST['username']) : "";
$service = isset($_POST['service']) ? mysqli_real_escape_string($conn, $_POST['service']) : "";
$employee = isset($_POST['employee']) ? mysqli_real_escape_string($conn, $_POST['employee']) : "";
$date = isset($_POST['date']) ? mysqli_real_escape_string($conn, $_POST['date']) : "";
$booking_time = isset($_POST['booking_time']) ? mysqli_real_escape_string($conn, $_POST['booking_time']) : "";
$duration = isset($_POST['duration']) ? mysqli_real_escape_string($conn, $_POST['duration']) : "";
$sql = "INSERT INTO `booking_api` (`username`, `service`, `employee`, `date`,`booking_time`, `duration`) VALUES ('$username', '$service','$employee', '$date', '$booking_time','$duration');";
$qur = mysqli_query($conn, $sql);
if ($qur) {
$id = mysqli_insert_id($conn);
// base64 encodes the header json
$encoded_header = base64_encode('{"alg": "HS256","typ": "JWT"}');

// base64 encodes the payload json
$encoded_payload = base64_encode('{"username":"$username", "service":"$service", "employee": "$employee", "date":"$date", "booking_time":"$booking_time", "duration":"$duration"}');
// base64 strings are concatenated to one that looks like this
$header_payload = $encoded_header . '.' . $encoded_payload;

//Setting the secret key
$secret_key = 'Octaviasecretkey';

// Creating the signature, a hash with the s256 algorithm and the secret key. The signature is also base64 encoded.
$signature = base64_encode(hash_hmac('sha256', $header_payload, $secret_key, true));

// Creating the JWT token by concatenating the signature with the header and payload, that looks like this:
$jwt_token = $header_payload . '.' . $signature;

//listing the resulted  JWT
//echo $jwt_token;
$json = array("status" => 1, "msg" => "Congratulations, Booking Confirmed!");
} else {
$json = array("status" => 0, "msg" => "Request method not accepted");
}
}
/* Output header */
header('Content-type: application/json');
echo json_encode($json);

0

Решение

Задача ещё не решена.

Другие решения

Других решений пока нет …

По вопросам рекламы ammmcru@yandex.ru
Adblock
detector