Compare commits

..

No commits in common. "75058e98b04d9094ec1b2fd2eec0dfd6887ddd5a" and "mpabi" have entirely different histories.

11 changed files with 178 additions and 16 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
*.swp

60
css/style.css Normal file
View File

@ -0,0 +1,60 @@
body {
/* Center the form on the page */
text-align: center;
}
form {
display: inline-block;
/* Form outline */
padding: 1em;
border: 1px solid #ccc;
border-radius: 1em;
}
p + p {
margin-top: 1em;
}
label {
/* Uniform size & alignment */
display: inline-block;
min-width: 90px;
text-align: right;
}
input,
textarea {
/* To make sure that all text fields have the same font settings
By default, textareas have a monospace font */
font: 1em sans-serif;
/* Uniform text field size */
width: 300px;
box-sizing: border-box;
/* Match form field borders */
border: 1px solid #999;
}
input:focus,
textarea:focus {
/* Additional highlight for focused elements */
border-color: #000;
}
textarea {
/* Align multiline text fields with their labels */
vertical-align: top;
/* Provide space to type some text */
height: 5em;
}
.button {
/* Align buttons with the text fields */
padding-left: 90px; /* same size as the label elements */
}
button {
/* This extra margin represent roughly the same space as the space
between the labels and their text fields */
margin-left: 0.5em;
}

View File

@ -4,21 +4,60 @@
<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>Test</p>
<label for="name">Name:</label>
<input type="text" id="name" name="user_name" />
</p>
<p>
<label for="mail">Email:</label>
<input type="email" id="mail" name="user_email" />
</p>
<p>
<label for="msg">Message:</label>
<textarea id="msg" name="user_message"></textarea>
</p>
</form>
</body>
</html>
<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>

10
php/__ Normal file
View File

@ -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"
}'

13
php/post.php Normal file
View File

@ -0,0 +1,13 @@
<?php
$con = mysqli_connect("192.168.80.31", "root", "secret", "db");
$data = json_decode(file_get_contents('php://input'), true);
$kw = "INSERT INTO Persons (LastName, FirstName, Email, Subject, Path) VALUES ('{$data['ln']}', '{$data['fn']}', '{$data['email']}', '{$data['subject']}', '{$data['path']}')";
$ans = mysqli_query($con, $kw);
echo json_encode($kw);
?>

10
script/__curl Normal file
View File

@ -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"
}'

2
script/__pwsh Normal file
View File

@ -0,0 +1,2 @@
Invoke-RestMethod -Uri "http://192.168.80.31:8080/p10.10/php/post.php" -Method Post -ContentType "application/json" -Body '{"ln": "Kowalski", "fn": "Jan", "email": "jan.kowalski@example.com", "subject": "Test subject", "path": "/path/to/photo.jpg"}'

BIN
sql/.init.sql.swp Normal file

Binary file not shown.

14
sql/init.sql Normal file
View File

@ -0,0 +1,14 @@
CREATE TABLE Persons (
PersonID int primary key auto_increment,
LastName varchar(255),
FirstName varchar(255),
Email varchar(255),
Subject varchar(255),
Path varchar(255)
);
INSERT INTO Persons (LastName, FirstName, Email, Subject, Path)
VALUES
('Smith', 'John', 'john.smith@example.com', 'Math', '/path/to/johnsmith'),
('Doe', 'Jane', 'jane.doe@example.com', 'Physics', '/path/to/janedoe'),
('Brown', 'Charlie', 'charlie.brown@example.com', 'Chemistry', '/path/to/charliebrown');

14
sql/sql.sql Normal file
View File

@ -0,0 +1,14 @@
CREATE TABLE Persons (
PersonID int primary key auto_increment,
LastName varchar(255),
FirstName varchar(255),
Email varchar(255),
Subject varchar(255),
Path varchar(255)
);
INSERT INTO Persons (LastName, FirstName, Email, Subject, Path)
VALUES
('Smith', 'John', 'john.smith@example.com', 'Math', '/path/to/johnsmith'),
('Doe', 'Jane', 'jane.doe@example.com', 'Physics', '/path/to/janedoe'),
('Brown', 'Charlie', 'charlie.brown@example.com', 'Chemistry', '/path/to/charliebrown');

View File

@ -1 +0,0 @@
5ba1dd28707f6f4f2fdf11af8cf208f813dd4059