<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Subscription Form</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f0f0f0;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
}
.container {
background-color: #fff;
padding: 20px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
border-radius: 5px;
width: 300px;
text-align: center;
}
h2 {
margin-bottom: 20px;
}
input[type="text"], input[type="email"] {
width: 100%;
padding: 10px;
margin: 10px 0;
border: 1px solid #ccc;
border-radius: 5px;
}
button {
width: 100%;
padding: 10px;
background-color: #007BFF;
color: white;
border: none;
border-radius: 5px;
cursor: pointer;
}
button:hover {
background-color: #0056b3;
}
.error {
color: red;
display: none;
}
</style>
</head>
<body>
<div class="container">
<h2>Subscribe</h2>
<form id="subscriptionForm">
<input type="text" id="name" placeholder="Your Name" required>
<input type="email" id="email" placeholder="Your Email" required>
<button type="submit">Submit</button>
<p class="error" id="errorMessage">Please fill in all fields.</p>
</form>
</div>
<script>
document.getElementById('subscriptionForm').addEventListener('submit', function(event) {
event.preventDefault();
var name = document.getElementById('name').value;
var email = document.getElementById('email').value;
var errorMessage = document.getElementById('errorMessage');
if (name === '' || email === '') {
errorMessage.style.display = 'block';
return;
} else {
errorMessage.style.display = 'none';
}
var xhr = new XMLHttpRequest();
xhr.open("POST", "your_internal_email_endpoint_here", true);
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.send(JSON.stringify({
name: name,
email: email
}));
xhr.onload = function() {
if (xhr.status === 200) {
window.location.href = 'path_to_your_pdf_file.pdf';
} else {
errorMessage.textContent = 'An error occurred. Please try again.';
errorMessage.style.display = 'block';
}
};
});
</script>
</body>
</html>