<?php
	session_start();
	$user_id = $_SESSION['id'];

	$rating = $_POST['rating'];
	$komentar = $_POST['komentar'];

	// Koneksi ke database
    require '../functions.php';

	// Cek koneksi
	if ($conn->connect_error) {
		die("Koneksi gagal: " . $conn->connect_error);
	}

	// Insert data ke tabel testimoni
	$sql = "INSERT INTO tb_testimoni (user_id, rating, komentar) VALUES ('$user_id', '$rating', '$komentar')";
	if ($conn->query($sql) === TRUE) {
		echo "<script>alert('Testimoni berhasil diposting'); window.location.href='testimoni.php';</script>";
	} else {
		echo "Error: " . $sql . "<br>" . $conn->error;
	}

	$conn->close();
?>
