2018-12-16 20:05:52 +01:00
|
|
|
<?php if( !isset( $_SESSION ) ) session_start();
|
2018-12-06 00:58:20 +01:00
|
|
|
include "../settings/db_connect.php";
|
|
|
|
$_SESSION['message'] = '';
|
2018-12-12 21:20:00 +01:00
|
|
|
$post=$_GET['post'];
|
2018-12-16 20:05:52 +01:00
|
|
|
$user=$_SESSION['user'];
|
2018-12-06 00:58:20 +01:00
|
|
|
if ($_SERVER['REQUEST_METHOD'] == "POST"){
|
|
|
|
$rating = $mysqli->real_escape_string($_POST['rating']);
|
|
|
|
$_SESSION['rating'] = $rating;
|
2018-12-16 20:05:52 +01:00
|
|
|
$sql = "INSERT INTO rating (post_id, username, rating)"
|
|
|
|
. "Values ($post, '$user', $rating)";
|
2018-12-06 00:58:20 +01:00
|
|
|
|
|
|
|
if($mysqli->query($sql) === true){
|
|
|
|
$_SESSION['message'] = "Dodanie oceny się powiodło!";
|
2018-12-12 21:20:00 +01:00
|
|
|
header("location:post.php?post=$post");
|
2018-12-06 00:58:20 +01:00
|
|
|
}
|
|
|
|
else{
|
|
|
|
$_SESSION['message'] = "Nie udało się dodać ooceny!";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
?>
|