Skip to content

Commit b919bcd

Browse files
authored
Update index.html
1 parent 9937a3f commit b919bcd

File tree

1 file changed

+42
-2
lines changed

1 file changed

+42
-2
lines changed

index.html

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,15 +90,55 @@ <h3>Get in touch</h3>
9090
<p>Facebook: <a href="https://www.facebook.com/people/Atubra-Abraham/100072576882412/" target="_blank" rel="noopener">Atubra Abraham</a></p>
9191
</div>
9292

93-
<div class="contact-card neon-glow">
93+
<div class="contact-card neon-glow">
9494
<h3>Message</h3>
95-
<form action="https://formspree.io/f/xwpwvqaz" method="POST">
95+
<form id="contactForm">
9696
<input name="name" placeholder="Your name" required>
9797
<input name="email" type="email" placeholder="Your email" required>
9898
<textarea name="message" rows="4" placeholder="Your message" required></textarea>
9999
<button class="btn primary neon-btn" type="submit">Send</button>
100+
<p id="formStatus" style="margin-top:10px;"></p>
100101
</form>
101102
</div>
103+
104+
<script>
105+
const form = document.getElementById('contactForm');
106+
const status = document.getElementById('formStatus');
107+
108+
form.addEventListener('submit', function(event) {
109+
event.preventDefault(); // prevent page reload
110+
111+
const formData = new FormData(form);
112+
113+
fetch('https://formspree.io/f/xwpwvqaz', {
114+
method: 'POST',
115+
body: formData,
116+
headers: {
117+
'Accept': 'application/json'
118+
}
119+
}).then(response => {
120+
if (response.ok) {
121+
status.style.color = 'lime';
122+
status.textContent = '✅ Message sent successfully! Thank you.';
123+
form.reset();
124+
} else {
125+
response.json().then(data => {
126+
if (data.errors) {
127+
status.style.color = 'red';
128+
status.textContent = '❌ Error sending message: ' + data.errors.map(e => e.message).join(', ');
129+
} else {
130+
status.style.color = 'red';
131+
status.textContent = '❌ Something went wrong. Please try again later.';
132+
}
133+
});
134+
}
135+
}).catch(error => {
136+
status.style.color = 'red';
137+
status.textContent = '❌ Network error. Please try again later.';
138+
});
139+
});
140+
</script>
141+
102142
</div>
103143
</div>
104144
</section>

0 commit comments

Comments
 (0)