You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

30 lines
661 B

<?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);
?>