Message
Message
DOCTYPE html>
<html>
<head>
<title>Product details</title>
<script>
document.getElementById("f").addEventListener("submit", function(event) {
event.preventDefault();
input[type="text"],
textarea,
input[type="number"]{
width: calc(100% - 20px);
margin-bottom: 10px;
padding: 20px;
border: 1px solid #ccc;
border-radius: 3px;
box-sizing: border-box;
font-size: 20px;
}
textarea {
resize: vertical;
height: 100px; /* Adjust height as needed */
}
/* Style for the comment container */
.comment-container {
border: 1px solid #ccc;
background-color: #fff;
padding: 20px;
border-radius: 8px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
margin-bottom: 15px;
margin: 20px;
</style>
</head>
<body>
<header>
<center><img src="titree.jpg"></center>
<hr>
<nav>
<ul>
<li class="left"><a href="home.html">Home</a></li>
<li class="right"><a href="shop.php">Shop</a></li><br>
</ul>
</nav>
</header>
<div class='product-details-container'>
<?php
include '../controller/produitC.php';
if (isset($_GET['id'])) {
$product_id = $_GET['id'];
$product_details = $ProductC->getProductById($product_id);
if ($product_details->rowCount() > 0) {
while ($row = $product_details->fetch(PDO::FETCH_ASSOC)) {
echo '<div class="product-details">';
echo "<img src='products/" . $row["image"] . "'>";
echo '<h2>' . $row["nom"] . '</h2>';
echo '<p>' . $row["description"] . '</p>';
echo '<p><b>Price : ' . $row["prix"] . ' DT</b></p>';
echo '<button id="likeButton"><a href="like.php?id=' .
$row['id_produit'] . '">Like</a></button>';
echo'<p id="likeCount">Likes : ' . $row["nbr_like"] . '</p>';
echo '<button>Add to cart</button><br>';
echo '</div>';
}
}
}
?>
<?php
// Include the Comments Controller
include '../controller/noteC.php';
if ($success) {
// Redirect to the product details page after successful submission
echo"mess.innerHtml='Form submited successfuly'";
header("Location:detaille.php?id=$product_id");
exit();
} else {
// Handle the case if submission fails
echo "Error: Submission failed.";
}
} catch (PDOException $e) {
// Handle any database-related errors
echo "Database Error: " . $e->getMessage();
}
}
?>
<div class="comments">
<form id='f' method="post" action="">
<input type="hidden" name="product_id" value="<?php echo $product_id; ?>">
<input type="text" name="user_name" id="user_name" placeholder="Your Name">
<span id="userError" class="error"></span><br>
if (!isValid) {
event.preventDefault(); // Empêche la soumission du formulaire
}
});
</script>
</div>
<?php
// Include and instantiate the noteC class (assuming you have a PDO connection in
$db)
$notec = new noteC();