inf03-06.2022-z2/php/post.php

20 lines
372 B
PHP
Raw Permalink Normal View History

2024-11-13 13:47:17 +00:00
<?php
$dbhost = "localhost";
$dbuser = "root";
$dbpass = "";
$dbname = "db";
$con = mysqli_connect($dbhost, $dbuser, $dbpass, $dbname);
$rawData = file_get_contents('php://input');
$data = json_decode($rawData, true);
$kw = "INSERT INTO paliwa (nazwa, cena) VALUES ('{$data['nazwa']}', {$data['cena']} );";
echo json_encode($kw);
$ans = mysqli_query($con, $kw);
?>