Files
demo_sites/templates/template_4/site/newsletter.php
2026-05-17 18:29:30 -05:00

28 lines
773 B
PHP

<?php
function parseInput($data) {
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}
if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST['email'])) {
$to_email = 'noreply@createwebsites.pl';
$user_email = parseInput($_POST['email']);
$subject = "a user is asking for a newsletter";
$body = "<p>a user (<a href=\"mailto:$user_email\">$user_email</a>) is asking for a newsletter</p>";
$header.= "MIME-Version: 1.0\r\n";
$header.= "Content-Type: text/html; charset=ISO-8859-1\r\n";
$header.= "X-Priority: 1\r\n";
if ( mail($to_email, $subject, $body, $header)) {
echo("success");
} else {
echo("fail");
}
} else {
echo ("email cannot be empty");
}
?>