Skip to content

Instantly share code, notes, and snippets.

@manmar
Last active September 6, 2020 02:42
Show Gist options
  • Save manmar/30424fcc126bc98f0337635688f56935 to your computer and use it in GitHub Desktop.
Save manmar/30424fcc126bc98f0337635688f56935 to your computer and use it in GitHub Desktop.
<?php
$name = Trim(stripslashes($_POST['name']));
$email = Trim(stripslashes($_POST['email']));
$message = Trim(stripslashes($_POST['message']));
// validation
$validationOK=true;
if (!$validationOK) {
print "<meta http-equiv=\"refresh\" content=\"0;URL=error.html\">";
exit;
}
$formcontent=" Name: $name \n E-Mail: $email \n Message: $message";
$recipient = "email@example.com";
$subject = "Contact Form";
$mailheader = "From: $email \r\n";
// anti spam (hidden url input)
if(isset($_POST['url']) && $_POST['url'] == ''){
$success = mail($recipient, $subject, $formcontent, $mailheader);
}
if ($success){
print "<meta http-equiv=\"refresh\" content=\"0;URL=danke.html\">";
}
else{
print "<meta http-equiv=\"refresh\" content=\"0;URL=error.html\">";
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment