add post php
This commit is contained in:
parent
19265c6358
commit
5c7661e2d6
|
@ -0,0 +1,10 @@
|
||||||
|
curl -X POST http://192.168.80.31:8080/p10.10/php/post.php \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-d '{
|
||||||
|
"ln": "Kowalski",
|
||||||
|
"fn": "Jan",
|
||||||
|
"email": "jan.kowalski@example.com",
|
||||||
|
"subject": "Test subject",
|
||||||
|
"path": "/path/to/photo.jpg"
|
||||||
|
}'
|
||||||
|
|
26
php/post.php
26
php/post.php
|
@ -1,14 +1,14 @@
|
||||||
<?php
|
<?php
|
||||||
$polaczenie = mysqli_connect("172.19.0.3", "root", "secret", "bazqq");
|
|
||||||
$imie = $_POST['imie'];
|
$con = mysqli_connect("192.168.80.31", "root", "secret", "db");
|
||||||
$nazwisko = $_POST['nazwisko'];
|
|
||||||
$email = $_POST['email'];
|
$rawData = file_get_contents('php://input');
|
||||||
$photo = $_FILES['photo']['tmp_name'];
|
$data = json_decode($rawData, true);
|
||||||
$photoContent = null;
|
|
||||||
if (is_uploaded_file($photo)) {
|
$kw = "INSERT INTO Persons (LastName, FirstName, Email, Subject, Path) VALUES ('{$data['ln']}', '{$data['fn']}', '{$data['email']}', '{$data['subject']}', '{$data['path']}')";
|
||||||
$photoContent = addslashes(file_get_contents($photo));
|
$ans = mysqli_query($con, $kw);
|
||||||
}
|
|
||||||
$kwerenda = "INSERT INTO dane (imie, nazwisko, email, photo) VALUES ('$imie', '$nazwisko', '$email', '$photoContent')";
|
echo json_encode($kw);
|
||||||
mysqli_query($polaczenie, $kwerenda);
|
|
||||||
echo json_encode($response);
|
?>
|
||||||
?>
|
|
||||||
|
|
Loading…
Reference in New Issue