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"){
|
|
|
|
$tekst = $mysqli->real_escape_string($_POST['tekst']);
|
|
|
|
$_SESSION['tekst'] = $tekst;
|
2018-12-16 20:05:52 +01:00
|
|
|
$sql = "INSERT INTO comments (post_id, username, tekst)"
|
|
|
|
. "Values ('$post' , '$user' , '$tekst')";
|
2018-12-06 00:58:20 +01:00
|
|
|
if($mysqli->query($sql) === true){
|
|
|
|
$_SESSION['message'] = "Dodanie komentarza 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ć komentarza!";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
?>
|