-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsubscribe.html
More file actions
73 lines (63 loc) · 2.48 KB
/
subscribe.html
File metadata and controls
73 lines (63 loc) · 2.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Subscribe - Machina iO</title>
<link rel="stylesheet" href="styles.css">
<link rel="icon" href="favicon.ico" type="image/x-icon">
</head>
<body>
<div class="container">
<div class="header">
<div class="logo">
<a href="index.html">
<img src="logo.png" alt="Machina iO Logo">
</a>
</div>
<div class="nav">
<a href="about.html">about</a>
<a href="subscribe.html">subscribe</a>
</div>
</div>
<div class="content">
<form id="subscribe-form" class="subscribe-form">
<div class="form-group">
<input type="email" id="email" name="email" required placeholder="your@email.com">
</div>
<button type="submit" class="submit-btn">Subscribe</button>
</form>
<div id="success-message" class="success-message" style="display: none;">
Thank you for subscribing!
</div>
</div>
</div>
<script>
const ZAPIER_HOOK = 'https://hooks.zapier.com/hooks/catch/22684483/2pt9snk/';
document
.getElementById('subscribe-form')
.addEventListener('submit', async function(e) {
e.preventDefault();
const email = e.target.email.value.trim().toLowerCase();
if (!email) return alert('Please enter a valid email.');
// build a urlencoded body
const formBody = new URLSearchParams({ email });
try {
const resp = await fetch(ZAPIER_HOOK, {
method: 'POST',
body: formBody
});
console.log('Status:', resp.status, resp.statusText);
const text = await resp.text();
console.log('Response body:', text);
if (!resp.ok) throw new Error(`Zapier error: ${resp.status}`);
e.target.style.display = 'none';
document.getElementById('success-message').style.display = 'block';
} catch (err) {
console.error(err);
alert('Oops—something went wrong. Please try again later.');
}
});
</script>
</body>
</html>