p17.10/index.php

64 lines
1.7 KiB
PHP
Raw Normal View History

2024-10-10 10:46:27 +00:00
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
2024-10-10 12:00:05 +00:00
<link rel="stylesheet" href="css/style.css">
2024-10-10 10:46:27 +00:00
</head>
<body>
2024-10-10 12:00:05 +00:00
<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>
2024-10-10 13:45:55 +00:00
<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>
2024-10-10 12:00:05 +00:00
</body>
2024-10-10 12:06:18 +00:00
</html>