diff --git a/blog-post/comment.php b/blog-post/comment.php
index ecb7013..6a0b8dc 100644
--- a/blog-post/comment.php
+++ b/blog-post/comment.php
@@ -1,13 +1,13 @@
-real_escape_string($_POST['tekst']);
$_SESSION['tekst'] = $tekst;
- $sql = "INSERT INTO comments (tekst)"
- . "Values ('$tekst')";
-
+ $sql = "INSERT INTO comments (post_id, username, tekst)"
+ . "Values ('$post' , '$user' , '$tekst')";
if($mysqli->query($sql) === true){
$_SESSION['message'] = "Dodanie komentarza się powiodło!";
header("location:post.php?post=$post");
diff --git a/blog-post/css/style.css b/blog-post/css/style.css
index 6edc748..c0ffc79 100644
--- a/blog-post/css/style.css
+++ b/blog-post/css/style.css
@@ -29,6 +29,7 @@ z {
}
+
post {
font-size: 18px;
@@ -122,8 +123,9 @@ post {
line-height: 1.3;
font-weight: 300;
text-align: left;
-
}
+
+
.name-desc po
{ font-style: italic;
font-size: 19px;
@@ -284,4 +286,5 @@ object-fit:scale-down;
.rate > input:checked ~ label:hover ~ label,
.rate > label:hover ~ input:checked ~ label {
color: #f4c741;
-}
\ No newline at end of file
+}
+
diff --git a/blog-post/post.php b/blog-post/post.php
index b322ed3..068a058 100644
--- a/blog-post/post.php
+++ b/blog-post/post.php
@@ -1,6 +1,8 @@
+
+
prepare("SELECT blog_id FROM post WHERE post_id =$post"))
@@ -15,6 +17,8 @@ if ($sql = $mysqli->prepare("SELECT blog_id FROM post WHERE post_id =$post"))
$sql->close();
?>
+
+
-
prepare("SELECT ROUND(AVG(R1.rating),1) as averageRating FROM rating R1 RIGHT JOIN (SELECT MAX(R2.timestamp) AS timestamp FROM rating R2 GROUP BY R2.username) R2 ON R1.timestamp=R2.timestamp WHERE post_id=$post"))
+{
+ $sql->execute();
+ $sql->bind_result($averageRating);
+ while ($sql->fetch()){}}
+//ocena uzytkownika
+if(!empty($_SESSION['user'])){
+$user=$_SESSION['user'];
+if ($sql = $mysqli->prepare("SELECT rating FROM rating WHERE post_id=$post AND username='$user'"))
+{
+ $sql->execute();
+ $sql->bind_result($userRating);
+while ($sql->fetch()){}} }
+
$trash = '';
if ($sql = $mysqli->prepare("SELECT * FROM post WHERE post_id =$post"))
{
@@ -88,8 +106,33 @@ if ($sql = $mysqli->prepare("SELECT * FROM post WHERE post_id =$post"))
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Średnia ocena:
+
+
+
+
+
+
+
+
-
+
+
+
+
+
+
+
+
+
close();
}
@@ -132,15 +189,16 @@ else die( "Błąd w zapytaniu SQL! Sprawdź kod SQL w PhpMyAdmin." );
-if ($sql = $mysqli->prepare("SELECT * FROM comments ORDER BY comment_id"))
+if ($sql = $mysqli->prepare("SELECT comments.comment_id, comments.post_id, comments.username, comments.tekst, comments.data_dodania, comments.data_modyfikacji, user.user_id FROM comments LEFT JOIN user ON comments.username=user.username WHERE post_id =$post ORDER BY comment_id"))
{
$sql->execute();
- $sql->bind_result($comment_id,$post_id,$username,$tekst,$data_dodania, $data_modyfikacji); ?>
-
Komentarze
+ $sql->bind_result($comment_id,$post_id,$username,$tekst,$data_dodania, $data_modyfikacji, $user_id); ?>
+
Komentarze
fetch())
{ ?>
+
@@ -148,8 +206,30 @@ if ($sql = $mysqli->prepare("SELECT * FROM comments ORDER BY comment_id"))
$sql->close();
$mysqli->close();
} ?>
+
+
Dodaj komentarz:
+
+
+
+
+
+
+
+
diff --git a/blog-post/rating.php b/blog-post/rating.php
index 81331c2..a6f2d1e 100644
--- a/blog-post/rating.php
+++ b/blog-post/rating.php
@@ -1,12 +1,13 @@
-real_escape_string($_POST['rating']);
$_SESSION['rating'] = $rating;
- $sql = "INSERT INTO rating (rating)"
- . "Values ($rating)";
+ $sql = "INSERT INTO rating (post_id, username, rating)"
+ . "Values ($post, '$user', $rating)";
if($mysqli->query($sql) === true){
$_SESSION['message'] = "Dodanie oceny się powiodło!";