EOT; $footer = <<< EOT EOT; $guest_form = <<< EOT

Guest Book





EOT; echo $header; echo $guest_form; $DBServer = '127.0.0.1'; $DBUser = 'root'; $DBPass = ''; $DBName = 'lab9'; $conn = new mysqli($DBServer, $DBUser, $DBPass, $DBName); if ($conn->connect_error){ die('Error: ' . $conn->connect_errno); } $results = $conn->query("SELECT name, email, comment, comment_timestamp FROM guestbook;"); if (isset($_POST['submit'])){ $name = "'" . $conn->real_escape_string($_POST['name']) . "'"; $email = "'" . $conn->real_escape_string($_POST['email']) . "'"; $comment = "'" . $conn->real_escape_string($_POST['comment']) . "'"; $sql = $conn->query("INSERT INTO guestbook(name, email, comment) VALUES($name, $email, $comment);"); if ($sql === false){ die('Error: ' . $conn->errno); } while($row = $results->fetch_assoc()) { echo $row['name'] . " "; echo $row['email'] . " "; echo $row['comment'] . " "; echo $row['comment_timestamp'] . " 
"; } } else { while($row = $results->fetch_assoc()) { echo $row['name'] . " "; echo $row['email'] . " "; echo $row['comment'] . " "; echo $row['comment_timestamp'] . " 
"; } } echo $footer;