Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 21 additions & 7 deletions contact/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,26 +38,31 @@

<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/animejs@3.2.1/lib/anime.min.js"></script>
<script src="https://smtpjs.com/v3/smtp.js">
</script>
</head>

<body>
<!-- Navbar -->
<div id="navbar"></div>

<!-- Contact Us Section -->
<section id="contact" class="py-5">
<div class="container">
<h2 class="text-center mb-4">Contact Us</h2>
<div id="contact" class="container">
<h1 class="text-center mb-4">Contact Us</h1>
<p class="text-center fs-5">
<i class="bi-envelope-fill"></i>
hackathon.d211@gmail.com
</p>
<div class="row justify-content-center">
<div class="col-lg-9 col-md-10 col-sm-12">
<form action="#" method="POST">
<form id="contactForm">
<div class="mb-3">
<label for="name" class="form-label">Full Name</label>
<input
type="text"
class="form-control"
id="name"
placeholder="Your name"
placeholder="John Smith"
required
/>
</div>
Expand All @@ -67,7 +72,17 @@ <h2 class="text-center mb-4">Contact Us</h2>
type="email"
class="form-control"
id="email"
placeholder="Your email"
placeholder="smith@gmail.com"
required
/>
</div>
<div class="mb-3">
<label for="name" class="form-label">Subject</label>
<input
type="text"
class="form-control"
id="subject"
placeholder="Subject Line"
required
/>
</div>
Expand All @@ -88,7 +103,6 @@ <h2 class="text-center mb-4">Contact Us</h2>
</div>
</div>
</div>
</section>

<!-- Footer -->
<div id="footer"></div>
Expand Down
44 changes: 44 additions & 0 deletions contact/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
document.addEventListener("DOMContentLoaded", () => {
const contactForm = document.getElementById("contactForm");
contactForm.addEventListener("submit", function (e) {
e.preventDefault();

const name = document.getElementById("name").value;
const email = document.getElementById("email").value;
const subject = document.getElementById("subject").value;
const message = document.getElementById("message").value;

const body = `
<p><strong>Name:</strong> ${name}</p>
<p><strong>Email:</strong> ${email}</p>
<p><strong>Subject:</strong> ${subject}</p>
<p><strong>Message:</strong></p>
<p>${message}</p>
`;

sendEmail(subject, body);
});

function sendEmail(subject, message) {
Email.send({
Host: "smtp.elasticemail.com",
Username: "hackathon.d211@gmail.com",
Password: "4CE2D4A17E09D6B84BC7E903F8300DA512C6",
To: "hackathon.d211@gmail.com",
From: "hackathon.d211@gmail.com",
Subject: "Message from Website: " + subject,
Body: message,
Port: 2525,
})
.then((response) => {
console.log("", response)
if (response === "OK") {
alert("Message sent successfully!");
contactForm.reset();
} else {
alert("Failed to send message. Please try again later.");
}
})
.catch((error) => console.error("Error:", error));
}
});
4 changes: 3 additions & 1 deletion contact/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@ body {

#contact {
padding: 50px 0;
max-width: 70%;
}

h2 {

h1 {
font-size: 2.5rem;
font-weight: 700;
color: var(--primary-color);
Expand Down