From: bochard Date: Sat, 28 Feb 2026 05:43:46 +0000 (+0800) Subject: added honeypot to guestbook and changed path for scripts and stylesheets X-Git-Url: https://git.bochard.net/?a=commitdiff_plain;p=mysite.git added honeypot to guestbook and changed path for scripts and stylesheets --- diff --git a/guestbook.php b/guestbook.php index b3ec37e..8085e52 100644 --- a/guestbook.php +++ b/guestbook.php @@ -4,7 +4,8 @@ head([ "title" => "guestbook", "meta" => [ ["name" => "description", "content" => "sign my guestbook"] - ] + ], + "css" => ["/stylesheet/guestbook.css"] ]); ?> @@ -16,9 +17,6 @@ head([
query("SET time_zone='+08:00';"); // check connection - if($conn->connect_error){ + if($conn->connect_error) { die("Connection failed: {$conn->connect_error}"); } // entry submission - if ($_SERVER["REQUEST_METHOD"] == "POST"){ + if ($_SERVER["REQUEST_METHOD"] == "POST") { + + // honeypot check + if(!empty($_POST['honeypot'])) { + header("Location: " . $_SERVER["PHP_SELF"]); + die(); + }; + $name = htmlspecialchars($_POST['name'], ENT_QUOTES, "UTF-8"); $country = htmlspecialchars($_POST['country'], ENT_QUOTES, "UTF-8"); $website = htmlspecialchars($_POST['website'], ENT_QUOTES, "UTF-8"); @@ -52,13 +57,13 @@ head([ VALUES (?, ?, ?, ?, ?, ?);"; $stmt = $conn->prepare($sql); - if(!$stmt){ + if(!$stmt) { die("Prepare failed: {$conn->error}"); } // s = string $stmt->bind_param("ssssss", $name, $country, $website, $email, $comment, $ip_addr); - if(!$stmt->execute()){ + if(!$stmt->execute()) { die("Execute failed: {$stmt->error}"); } @@ -84,6 +89,7 @@ head([

+

diff --git a/part/head.php b/part/head.php index 3178666..763c9a7 100644 --- a/part/head.php +++ b/part/head.php @@ -44,7 +44,7 @@ function head(array $head = []) { ?> - "> + "> - +