summaryrefslogtreecommitdiff
path: root/guestbook/guestbook.php
diff options
context:
space:
mode:
Diffstat (limited to 'guestbook/guestbook.php')
-rw-r--r--guestbook/guestbook.php121
1 files changed, 0 insertions, 121 deletions
diff --git a/guestbook/guestbook.php b/guestbook/guestbook.php
deleted file mode 100644
index 4f96a04..0000000
--- a/guestbook/guestbook.php
+++ /dev/null
@@ -1,121 +0,0 @@
-<?php
-// Function to sanitize user input
-function sanitize_input($data) {
- $data = trim($data);
- $data = stripslashes($data);
- $data = htmlspecialchars($data);
- return $data;
-}
-
-// Check if form has been submitted
-if ($_SERVER["REQUEST_METHOD"] == "POST") {
- // Get form data
- $name = sanitize_input($_POST["name"]);
- $message = sanitize_input($_POST["message"]);
-
- // Validate form data
- $errors = [];
- if (empty($name)) {
- $errors[] = "Name is required";
- }
- if (empty($message)) {
- $errors[] = "Message is required";
- }
-
- // If no errors, add entry to guestbook
- if (empty($errors)) {
- $entry = $name . "|" . $message . "\n";
- file_put_contents("entries.txt", $entry, FILE_APPEND | LOCK_EX);
- }
-}
-
-// Display guestbook entries
-$entries = file("entries.txt");
-?>
-
-<!DOCTYPE html>
-<html>
- <head>
- <title>Guestbook</title>
- <style>
- body {
- background-color: black;
- color: white;
- font-family: Arial, sans-serif;
- font-size: 16px;
- }
- form {
- display: flex;
- flex-direction: column;
- margin-bottom: 20px;
- }
- label {
- margin-bottom: 10px;
- }
- input, textarea {
- font-family: Arial, sans-serif;
- font-size: 16px;
- padding: 5px;
- margin-bottom: 10px;
- border-radius: 3px;
- border: none;
- }
- textarea {
- height: 100px;
- }
- input[type="submit"] {
- background-color: white;
- color: black;
- font-weight: bold;
- border-radius: 3px;
- border: none;
- padding: 10px;
- cursor: pointer;
- }
- .entry {
- margin-bottom: 20px;
- }
- .entry h3 {
- font-size: 18px;
- margin-bottom: 10px;
- }
- .entry p {
- font-size: 16px;
- margin-bottom: 10px;
- }
- .entry a {
- color: red;
- margin-left: 10px;
- }
- </style>
- </head>
- <body>
- <h1>Guestbook</h1>
- <?php
- // If there are errors, display them
- if (!empty($errors)) {
- echo "<ul>";
- foreach ($errors as $error) {
- echo "<li>" . $error . "</li>";
- }
- echo "</ul>";
- }
- ?>
- <form method="post">
- <label for="name">Name:</label>
- <input type="text" id="name" name="name">
- <label for="message">Message:</label>
- <textarea id="message" name="message"></textarea>
- <input type="submit" value="Submit">
-</form>
-<h2>Entries:</h2>
-<?php
-foreach ($entries as $entry) {
- list($name, $message) = explode("|", $entry);
- echo "<div class='entry'>";
- echo "<h3>" . htmlspecialchars($name) . "</h3>";
- echo "<p>" . htmlspecialchars($message) . "</p>";
- echo "</div>";
-}
-?>
-