Review adder made limit 1 review per user
This commit is contained in:
parent
9a3cdd975a
commit
cf7d60708e
@ -358,48 +358,6 @@ $productId = isset($_GET['id']) ? (int)$_GET['id'] : 0;
|
|||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="review-add">
|
|
||||||
<h2 class="reviews-title">Füge deine Bewertung hinzu!</h2>
|
|
||||||
|
|
||||||
<?php
|
|
||||||
// Die Logik bleibt hier unten im Block!
|
|
||||||
if (
|
|
||||||
$_SERVER['REQUEST_METHOD'] === 'POST' &&
|
|
||||||
isset($_POST['submit_review']) &&
|
|
||||||
isset($_SESSION['user_id'])
|
|
||||||
) {
|
|
||||||
$rating = (int)$_POST['rating'];
|
|
||||||
$comment = trim($_POST['comment']);
|
|
||||||
$userID = $_SESSION['user_id'];
|
|
||||||
|
|
||||||
if ($rating >= 1 && $rating <= 5 && !empty($comment)) {
|
|
||||||
|
|
||||||
$stmtInsertRev = mysqli_prepare(
|
|
||||||
$conn,
|
|
||||||
"INSERT INTO reviews (userID, productID, rating, comment) VALUES (?, ?, ?, ?)"
|
|
||||||
);
|
|
||||||
|
|
||||||
if ($stmtInsertRev) {
|
|
||||||
mysqli_stmt_bind_param(
|
|
||||||
$stmtInsertRev,
|
|
||||||
"iiis",
|
|
||||||
$userID,
|
|
||||||
$productId,
|
|
||||||
$rating,
|
|
||||||
$comment
|
|
||||||
);
|
|
||||||
|
|
||||||
mysqli_stmt_execute($stmtInsertRev);
|
|
||||||
mysqli_stmt_close($stmtInsertRev);
|
|
||||||
|
|
||||||
// TRICK: JavaScript-Weiterleitung anstelle von PHP-Header!
|
|
||||||
echo "<script>window.location.href = 'productpage.php?id=" . $productId . "';</script>";
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
|
|
||||||
<div class="review-add">
|
<div class="review-add">
|
||||||
<h2 class="reviews-title">Füge deine Bewertung hinzu!</h2>
|
<h2 class="reviews-title">Füge deine Bewertung hinzu!</h2>
|
||||||
|
|
||||||
@ -461,7 +419,7 @@ $productId = isset($_GET['id']) ? (int)$_GET['id'] : 0;
|
|||||||
<div class="review-card">
|
<div class="review-card">
|
||||||
<?php if (!isset($_SESSION['user_id'])): ?>
|
<?php if (!isset($_SESSION['user_id'])): ?>
|
||||||
<div class="review-login-prompt">
|
<div class="review-login-prompt">
|
||||||
<p class="review-login-msg">Du musst eingeloggt sein, um eine Bewertung abzugeben.</p>
|
<p style="color: #cbd5e1; margin-bottom: 1rem;">Du musst eingeloggt sein, um eine Bewertung abzugeben.</p>
|
||||||
<a href="login.php">
|
<a href="login.php">
|
||||||
<input class="auth__submit" type="button" value="Zum Einloggen">
|
<input class="auth__submit" type="button" value="Zum Einloggen">
|
||||||
</a>
|
</a>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user