File: /home/internet/public_html/vij.co/php/subscribe2.php
<?php
// Variables
$name = trim($_POST['name']);
$email = trim($_POST['email']);
// Email address validation - works with php 5.2+
function is_email_valid($email) {
return filter_var($email, FILTER_VALIDATE_EMAIL);
}
if( isset($name) && isset($email) && is_email_valid($email) ) {
// Avoid Email Injection and Mail Form Script Hijacking
$pattern = "/(content-type|bcc:|cc:|to:)/i";
if( preg_match($pattern, $name) || preg_match($pattern, $email) ) {
exit;
}
// Email will be send
$to = "mail@themedept.com"; // Change with your email address
$subject = "New contact from GetLeads"; // If you want a default subject
// HTML Elements for Email Body
$body = <<<EOD
<strong>Name:</strong> $name <br>
<strong>Email:</strong> <a href="mailto:$email?subject=feedback" "email me">$email</a> <br> <br>
EOD;
//Must end on first column
$headers = "From: $name <$email>\r\n";
$headers .= 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
// PHP email sender
mail($to, $subject, $body, $headers);
}
?>