Skip to content

Commit

Permalink
Add reviews
Browse files Browse the repository at this point in the history
  • Loading branch information
iyannn03 authored Oct 17, 2024
1 parent 25ae86d commit dbdf556
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions reviews.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$name = htmlspecialchars($_POST['name']);
$review = htmlspecialchars($_POST['review']);
$rating = $_POST['rating'];

$conn = new mysqli("localhost", "username", "password", "coffeeshop_db");

if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}

$sql = "INSERT INTO reviews (name, review, rating) VALUES ('$name', '$review', '$rating')";

if ($conn->query($sql) === TRUE) {
echo "Review submitted successfully!";
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}

$conn->close();
}
?>

0 comments on commit dbdf556

Please sign in to comment.