diff --git a/guestbook.php b/guestbook.php index 5cc2e59..39b24a8 100644 --- a/guestbook.php +++ b/guestbook.php @@ -13,14 +13,19 @@ if(isset($_POST['entry']) && $_POST['entry'] != "") { $id = $_SESSION['userid']; - $entry = $_POST['entry']; + $entry = strip_tags($_POST['entry']); $query = "select * from `users` where `id` = '$id' LIMIT 1"; $result = $db->query($query); if ($row = $result->fetch_assoc()) { $username = $row['username']; } - $query = "INSERT INTO `guestbook` (`username`, `entry`) VALUES ('$username', '$entry');"; - $result = $db->query($query); + $query = "INSERT INTO `guestbook` (`username`, `entry`) VALUES (?, ?);"; + + $stmt = $db->prepare($query); + $stmt->bind_param("ss", $username, $entry); + $stmt->execute(); + $result = $stmt->get_result(); + $db->commit(); print('