29 lines
558 B
PHP
29 lines
558 B
PHP
<?php
|
|
|
|
$dbhost="192.168.82.71";
|
|
//$dbhost="172.18.0.2";
|
|
$dbuser="root";
|
|
$dbpass="secret";
|
|
$dbname="db";
|
|
|
|
$con = mysqli_connect($dbhost, $dbuser, $dbpass, $dbname);
|
|
|
|
if (!$con) {
|
|
die(json_encode([
|
|
'error' => 'Nie można połączyć się z bazą danych',
|
|
'details' => mysqli_connect_error()
|
|
]));
|
|
}
|
|
|
|
$rawData = file_get_contents('php://input');
|
|
|
|
$data = json_decode($rawData, true);
|
|
|
|
$kw = "INSERT INTO zamowienia1(nazwa, cena) VALUES ('{$data ['nazwa']}',{$data['cena']});";
|
|
|
|
echo json_encode($kw);
|
|
|
|
$ans = mysqli_query($con, $kw);
|
|
|
|
?>
|