mirror of
https://github.com/t404owo/t404null.git
synced 2025-12-12 09:58:46 +00:00
test #1
This commit is contained in:
50
assets/js/mail.js
Normal file
50
assets/js/mail.js
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
import { createClient } from "https://cdn.jsdelivr.net/npm/@supabase/supabase-js/+esm";
|
||||||
|
|
||||||
|
const supabaseUrl = "https://owbamcqdmqetrgcznxva.supabase.co";
|
||||||
|
const supabaseKey =
|
||||||
|
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Im93YmFtY3FkbXFldHJnY3pueHZhIiwicm9sZSI6ImFub24iLCJpYXQiOjE3MjI5NDU5NjIsImV4cCI6MjAzODUyMTk2Mn0.xNen7b513ZGwJ-Qu5iZ6K8qrmvy4QVjS10wiYbEEwKc";
|
||||||
|
//anon key, you cant access private stuffs or add hilarious stuffs w/ this...
|
||||||
|
//(unless sending me some malicious links but I delete your msg)
|
||||||
|
//the moment you notice you need an API endpoint.
|
||||||
|
const supabase = createClient(supabaseUrl, supabaseKey);
|
||||||
|
|
||||||
|
const form = document.getElementById("mail-form"),
|
||||||
|
nameInput = document.getElementById("name"),
|
||||||
|
emailInput = document.getElementById("email"),
|
||||||
|
subjectInput = document.getElementById("subject"),
|
||||||
|
messageInput = document.getElementById("message"),
|
||||||
|
statusMessage = document.querySelector(".box");
|
||||||
|
|
||||||
|
form.addEventListener("submit", async (e) => {
|
||||||
|
e.preventDefault();
|
||||||
|
|
||||||
|
const name = nameInput.value.trim();
|
||||||
|
const email = emailInput.value.trim();
|
||||||
|
const subject = subjectInput.value.trim();
|
||||||
|
const message = messageInput.value.trim();
|
||||||
|
|
||||||
|
if (!name || !email || !subject || !message ||
|
||||||
|
name.length==0 || email.length==0 || subject.length==0 || message.length==0) {
|
||||||
|
statusMessage.textContent = "Please fill in all fields.";
|
||||||
|
statusMessage.style.color = "FFDCDC";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
const { data, error } = await supabase
|
||||||
|
.from("mail")
|
||||||
|
.insert([{ name, email, subject, message }]);
|
||||||
|
|
||||||
|
if (error) {
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
|
||||||
|
statusMessage.textContent = "Message sent successfully!";
|
||||||
|
statusMessage.style.color = "DDF6D2";
|
||||||
|
form.reset();
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error sending message:", error);
|
||||||
|
statusMessage.textContent = "Error sending message. Please try again.";
|
||||||
|
statusMessage.style.color = "FFDCDC";
|
||||||
|
}
|
||||||
|
});
|
||||||
@@ -7,6 +7,7 @@ I write/make/produce EDM music(DTM), and for every releases I'll post my music o
|
|||||||
<link rel="icon" type="image/x-icon" href="https://cdn.glitch.global/2d9e31c1-a947-46cd-9fd2-8c92be70abe2/t404_null%20Icon.png" />
|
<link rel="icon" type="image/x-icon" href="https://cdn.glitch.global/2d9e31c1-a947-46cd-9fd2-8c92be70abe2/t404_null%20Icon.png" />
|
||||||
<meta charset="UTF-8" />
|
<meta charset="UTF-8" />
|
||||||
<link rel="stylesheet" type="text/css" href="/assets/css/main.css" />
|
<link rel="stylesheet" type="text/css" href="/assets/css/main.css" />
|
||||||
|
<script src="/assets/js/mail.js" type="module"></script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<nav>
|
<nav>
|
||||||
@@ -231,7 +232,7 @@ I write/make/produce EDM music(DTM), and for every releases I'll post my music o
|
|||||||
(Or) Contact me here
|
(Or) Contact me here
|
||||||
</h1>
|
</h1>
|
||||||
<div class="contact-email">
|
<div class="contact-email">
|
||||||
<form method="POST" class="form">
|
<form method="POST" class="form" id="mail-form">
|
||||||
<label for="name">Subject:</label>
|
<label for="name">Subject:</label>
|
||||||
<input type="text" name="name" class="inputbox" placeholder="Your Name" required>
|
<input type="text" name="name" class="inputbox" placeholder="Your Name" required>
|
||||||
<br>
|
<br>
|
||||||
@@ -245,7 +246,7 @@ I write/make/produce EDM music(DTM), and for every releases I'll post my music o
|
|||||||
<textarea type="text" name="message" class="inputbox" placeholder="Message here." required></textarea>
|
<textarea type="text" name="message" class="inputbox" placeholder="Message here." required></textarea>
|
||||||
<br>
|
<br>
|
||||||
<br>
|
<br>
|
||||||
<!-- div class="error_box" /div-->
|
<div class="box"></div>
|
||||||
<button type="submit" class="formbutton">Submit</button>
|
<button type="submit" class="formbutton">Submit</button>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user