
7 changed files with 122 additions and 0 deletions
@ -0,0 +1,22 @@ |
|||||
|
<!DOCTYPE html> |
||||
|
<html lang="en"> |
||||
|
<head> |
||||
|
<meta charset="UTF-8"> |
||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0"> |
||||
|
<title>Document</title> |
||||
|
</head> |
||||
|
<body> |
||||
|
<form action="formular_post.php" method="post"> |
||||
|
<label for="name">name:</label> |
||||
|
<input type="text" name="name" id="name"> |
||||
|
<br> |
||||
|
<label for="email">email:</label> |
||||
|
<input type="email" name="email" id="email"> |
||||
|
<br> |
||||
|
<label for="text">text:</label> |
||||
|
<input type="text" name="text" id="text"> |
||||
|
<br> |
||||
|
<input type="submit" value="Save to book"> |
||||
|
</form> |
||||
|
</body> |
||||
|
</html> |
@ -0,0 +1,30 @@ |
|||||
|
<?php |
||||
|
$name = $_POST["name"]; |
||||
|
$email = $_POST["email"]; |
||||
|
$text = $_POST["text"]; |
||||
|
|
||||
|
$servername = "localhost"; |
||||
|
$username = "root"; |
||||
|
$password = "toor"; |
||||
|
$dbname = "wtl"; |
||||
|
|
||||
|
// Create connection |
||||
|
$conn = mysqli_connect($servername, $username, $password, $dbname); |
||||
|
// Check connection |
||||
|
if (!$conn) { |
||||
|
die("Connection failed: " . mysqli_connect_error()); |
||||
|
} |
||||
|
|
||||
|
$sql = "INSERT INTO kniha (name, email, text) |
||||
|
VALUES ('$name', '$email', '$text')"; |
||||
|
echo $sql; |
||||
|
|
||||
|
if (mysqli_query($conn, $sql)) { |
||||
|
echo "New record created successfully"; |
||||
|
header('Location: http://localhost/prace.php'); |
||||
|
} else { |
||||
|
echo "Error: " . $sql . "<br>" . mysqli_error($conn); |
||||
|
} |
||||
|
|
||||
|
mysqli_close($conn); |
||||
|
?> |
@ -0,0 +1,26 @@ |
|||||
|
<!DOCTYPE html> |
||||
|
<html lang="en"> |
||||
|
<head> |
||||
|
<meta charset="UTF-8"> |
||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0"> |
||||
|
<title>Document</title> |
||||
|
</head> |
||||
|
<body> |
||||
|
<h1>Pozdrav z HTML</h1> |
||||
|
<?php echo "<h2> pozdrav z PHP </h2>"; ?> |
||||
|
|
||||
|
<form action="post_welcome.php" method="post"> |
||||
|
<label for="name">name:</label> |
||||
|
<input type="text" name="name" id="name"> |
||||
|
<br> |
||||
|
<label for="mail">Email</label> |
||||
|
<input type="email" name="mail" id="mail"> |
||||
|
<br> |
||||
|
<input type="submit" value="SEND"> |
||||
|
</form> |
||||
|
|
||||
|
<hr> |
||||
|
|
||||
|
<a href="prace.php">PRACE S DATABSAZIIIIII</a> |
||||
|
</body> |
||||
|
</html> |
@ -0,0 +1,10 @@ |
|||||
|
<?php |
||||
|
// echo var_dump($_POST); |
||||
|
|
||||
|
$name = $_POST["name"]; |
||||
|
$mail = $_POST["mail"]; |
||||
|
|
||||
|
echo "Hello " . $name . ". We send email at ". $mail . " very soon. ☺"; |
||||
|
echo "<br>"; |
||||
|
echo '<a href="/"> HOME </a>'; |
||||
|
?> |
@ -0,0 +1,29 @@ |
|||||
|
<?php |
||||
|
$servername = "localhost"; |
||||
|
$username = "root"; |
||||
|
$password = "toor"; |
||||
|
$dbname = "wtl"; |
||||
|
|
||||
|
// Create connection |
||||
|
$conn = mysqli_connect($servername, $username, $password, $dbname); |
||||
|
|
||||
|
// Check connection |
||||
|
if (!$conn) { |
||||
|
die("Connection failed: " . mysqli_connect_error()); |
||||
|
} |
||||
|
|
||||
|
$sql = "SELECT * FROM kniha"; |
||||
|
$result = mysqli_query($conn, $sql); |
||||
|
|
||||
|
if (mysqli_num_rows($result) > 0) { |
||||
|
while($row = mysqli_fetch_assoc($result)) { |
||||
|
echo "<p> id: <b>" . $row["id"] . "</b>"; |
||||
|
echo " name: <b>" . $row["name"] . "</b>"; |
||||
|
echo " email: <b>" . $row["email"] . "</b>"; |
||||
|
echo " text: <b>" . $row["text"] . "</b>"; |
||||
|
echo "</p>"; |
||||
|
} |
||||
|
} else { |
||||
|
echo "0 results"; |
||||
|
} |
||||
|
?> |
@ -0,0 +1,3 @@ |
|||||
|
<?php |
||||
|
echo "My first PHP script!"; |
||||
|
?> |
@ -0,0 +1,2 @@ |
|||||
|
# Doučování WTL |
||||
|
|
Loading…
Reference in new issue