p17.10/index.php

64 lines
1.7 KiB
PHP

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" href="css/style.css">
</head>
<body>
<form action="/my-handling-form-page" method="post">
<p>
<label for="Lastname">LastName:</label>
<input type="text" id="Lastname" name="user_name" />
</p>
<p>
<label for="surname">FirstName:</label>
<input type="text" id="Firstname" name="user_name" />
</p>
<p>
<label for="mail">Email:</label>
<input type="email" id="mail" name="user_email" />
</p>
<p>
<label for="sub">Subject:</label>
<textarea id="sub" name="user_sub"></textarea>
</p>
<p>
<label for="path">Path:</label>
<textarea id="path" name="user_path"></textarea>
</p>
<p class="button">
<button type="submit">Send your message</button>
</p>
</form>
<script>
fetch("http://192.168.80.31:8080/p10.10/php/post.php", {
method: "POST",
headers: {
"Content-Type": "application/json" // Bezpośrednie przekazanie nagłówka
},
body: JSON.stringify({
"ln": "Kowalski",
"fn": "Jan",
"email": "jan.kowalski@example.com",
"subject": "Test subject",
"path": "/path/to/photo.jpg"
})
})
.then(response => {
return response.json(); // Oczekujemy odpowiedzi w formacie JSON
})
.then(data => {
console.log("Response from server:", data); // Wyświetlenie odpowiedzi z serwera
})
.catch(error => {
console.error("There was a problem with the fetch operation:", error);
});
</script>
</body>
</html>