пожалуйста, помогите мне. У меня очень небольшая проблема, но я не могу ее решить ... Я использую рейтинговую систему на php. всякий раз, когда я отправляю форму, значение рейтинга всегда вставляется как 1. Я все проверил, но не могу решить. Вот база данных
Вот HTML Форма
<form action="includes/review-script.php" method="post">
<input type="hidden" name="order_id" value="<?php echo $query_fetch->order_id; ?>">
<div class="modal-content">
<div class="modal-header">
<h3 class="modal-title has-icon ms-icon-round ">Add Review</h3>
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
</div>
<div class="modal-body">
<div class="col-xl-12 col-md-12 col-sm-12">
<input name="rating" id="review_rating" value="0" type="hidden" class="rating" data-min=0 data-max=5 data-step=1 data-size="xs">
<div class="star-ratings-sprite" style="float: left;margin-bottom: 10px;">
<span style="" id="review_rating_show" class="star-ratings-sprite-rating"></span>
</div>
</div>
<div class="ms-form-group has-icon">
<textarea name="review" class="form-control" placeholder="Write a review"></textarea>
</div>
</div>
<div class="modal-footer">
<button type="submit" name="submit" class="btn btn-primary shadow-none">Submit</button>
</div>
</div>
</form>
А вот php скрипт ..
<?php
if(isset($_POST['submit']))
{
$order_id = filter_var(htmlentities($_POST['order_id']),FILTER_SANITIZE_STRING);
$rating = filter_var(htmlentities($_POST['rating']),FILTER_SANITIZE_NUMBER_INT);
$user_id = $_SESSION['user_id'];
$review = filter_var(htmlentities($_POST['review']),FILTER_SANITIZE_STRING);
$create_date = date("F d, yy");
$query = "SELECT * from product_ratings WHERE order_id = '".$order_id."' AND user_id = '".$user_id."'";
$rating = $conn->prepare($query);
$rating->execute();
if($rating -> rowCount() > 0) {
header ("Location: //localhost/Aahar-food-delivery/my-orders.php?error=rating");
exit();
}
else
{
$sql = "INSERT INTO product_ratings(user_id, order_id, rating, review, create_date) VALUES(:user_id, :order_id, :rating, :review, :create_date)";
if($stmt = $conn->prepare($sql)){
$stmt->bindParam(":user_id", $user_id, PDO::PARAM_STR);
$stmt->bindParam(":order_id", $order_id, PDO::PARAM_STR);
$stmt->bindParam(":rating", $rating, PDO::PARAM_INT);
$stmt->bindParam(":review", $review, PDO::PARAM_STR);
$stmt->bindParam(":create_date", $create_date, PDO::PARAM_STR);
// Attempt to execute the prepared statement
if($stmt->execute()){
// Redirect to login page
header ("Location: //localhost/Aahar-food-delivery/my-orders.php?review=success");
} else{
echo "ERROR: Could not able to execute $sql. " . $e->getMessage();
header('Refresh:1;url=review-script.php');
}
// Close statement
unset($stmt);
}
}
}
?>