newsletter.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Subscribe | PHP Newsletter Form</title>
<meta name="description" content="A stylish PHP newsletter form with modern CSS design.">
<meta name="keywords" content="PHP, newsletter, email form, html css form, stylish php form">
<style>
body {
background: #f9f9f9;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}
.newsletter-box {
background: white;
padding: 30px;
border-radius: 10px;
box-shadow: 0 6px 15px rgba(0,0,0,0.1);
width: 300px;
text-align: center;
}
.newsletter-box h2 {
margin-bottom: 20px;
font-weight: 600;
}
input[type="email"] {
width: 100%;
padding: 10px;
border: 1px solid #ddd;
border-radius: 5px;
margin-bottom: 15px;
}
button {
width: 100%;
padding: 10px;
background: #4caf50;
border: none;
color: white;
font-size: 16px;
border-radius: 5px;
}
button:hover {
background: #45a049;
}
</style>
</head>
<body>
<form class="newsletter-box" action="subscribe.php" method="post">
<h2>Subscribe Now</h2>
<input type="email" name="email" placeholder="Enter your email" required>
<button type="submit">Subscribe</button>
</form>
</body>
</html>
subscribe.php
<?php
if (isset($_POST['email'])) {
$email = trim($_POST['email']);
$file = fopen("subscribers.txt", "a");
fwrite($file, $email . PHP_EOL);
fclose($file);
echo "Thank you for subscribing!";
}
?>