diff --git a/src/pages/site/guestbook.astro b/src/pages/site/guestbook.astro
index d8ab47a..4cc0f60 100644
--- a/src/pages/site/guestbook.astro
+++ b/src/pages/site/guestbook.astro
@@ -54,20 +54,22 @@ const pageTitle = "emma's guestbook"
{pageTitle}
-
comments
-
+
diff --git a/src/scripts/guestbook-send-comment.js b/src/scripts/guestbook-send-comment.js
index 6724c24..7ea29cd 100644
--- a/src/scripts/guestbook-send-comment.js
+++ b/src/scripts/guestbook-send-comment.js
@@ -1,14 +1,33 @@
import { createClient } from "@supabase/supabase-js";
-// this string provides public access to the db, it is not a secret key
+// Create a single supabase client for interacting with your database
const supabase = createClient(
"https://kddqzqkvjumaslnljhqv.supabase.co",
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImtkZHF6cWt2anVtYXNsbmxqaHF2Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NDAyMDM5NTEsImV4cCI6MjA1NTc3OTk1MX0.wXhRoE7Jh2aaCdPlBiqEI7F4yj8-7beoeWEPvtVn0kg"
);
-const { error } = await supabase.from("guestbook-comments").insert({
- name: "emma",
- website: "https://emmas.place",
- comment: "lmao",
- "bot-check": 17,
+const commentForm = document.querySelector("#add-comment");
+
+const name = commentForm.elements["name-input"];
+const website = commentForm.elements["website-input"];
+const question = commentForm.elements["math-question"];
+const comment = commentForm.elements["message-input"];
+
+const submit = async () => {
+ const nameValue = name.value;
+ const websiteValue = website.value;
+ const questionValue = parseInt(question.value);
+ const commentValue = comment.value;
+
+ const { error } = await supabase.from("guestbook-comments").insert({
+ name: nameValue,
+ website: websiteValue,
+ "bot-check": questionValue,
+ comment: commentValue,
+ });
+};
+
+commentForm.addEventListener("submit", (event) => {
+ event.preventDefault();
+ submit();
});