Contactform
// geef e-mail adres op van ontvanger
$mail_ontv = "michiel@lagom.eu";
// is niet 100% !!!
function checkmail($mail)
{
$email_host = explode("@", $mail);
$email_host = $email_host['1'];
$email_resolved = gethostbyname($email_host);
if ($email_resolved != $email_host && eregi("^[0-9a-z]([-_.~]?[0-9a-z])*@[0-9a-z]([-.]?[0-9a-z])*\\.[a-z]{2,4}$",$mail))
$valid = 1;
return $valid;
}
// als er niet op submit is gedrukt, of als er wel op is gedrukt maar niet alles ingevoerd is
if (!$_POST['submit'] || $_POST['submit'] && (!$_POST['name'] || !$_POST['company name'] || !$_POST['mail'] || !checkmail($_POST['mail']) || !$_POST['msggs'] || !$_POST['subject']))
{
if ($_POST['submit'] && (!$_POST['name'] || !$_POST['company name'] ||!$_POST['mail'] || !checkmail($_POST['mail']) || !$_POST['msggs'] || !$_POST['subject']))
{
echo "
You forgot to fill in either your Name, E-mailadress, subject or message. Or you ";
echo "filled in a wrong e-mailadress.
";
}
// form + tabel
echo "
";
}
// versturen naar
else
{
// set datum
$datum = date("d.m.Y H:i");
// set ip
$ip = $_SERVER['REMOTE_ADDR'];
$inhoud_mail = "===================================================\n";
$inhoud_mail .= "Michiel, je hebt mail ontvangen via de site\n";
$inhoud_mail .= "===================================================\n\n";
$inhoud_mail .= $_SERVER['SCRIPT_URI'] . "\n\n";
$inhoud_mail .= "Name: " . $_POST['name'] . "\n";
$inhoud_mail .= "Company Name: " . $_POST['company name'] . "\n";
$inhoud_mail .= "E-mail adress: " . $_POST['mail'] . "\n";
$inhoud_mail .= "Subject: " . $_POST['subject'] . "\n";
$inhoud_mail .= "Message: " . $_POST['msggs'] . "\n\n";
$inhoud_mail .= "Verstuurd op " . $datum . " via het ip " . $ip . "\n\n";
$inhoud_mail .= "===================================================\n\n";
$headers = "From: " . $_POST['name'] . " <" . $_POST['mail'] . ">";
$headers = stripslashes($headers);
$headers = str_replace("\n", "", $headers); // Verwijder \n
$headers = str_replace("\r", "", $headers); // Verwijder \r
$headers = str_replace("\"", "\\\"", str_replace("\\", "\\\\", $headers)); // Slashes van quotes
$_POST['subject'] = str_replace("\n", "", $_POST['subject']); // Verwijder \n
$_POST['subject'] = str_replace("\r", "", $_POST['subject']); // Verwijder \r
$_POST['subject'] = str_replace("\"", "\\\"", str_replace("\\", "\\\\", $_POST['subject'])); // Slashes van quotes
mail($mail_ontv, $_POST['subject'], $inhoud_mail, $headers);
echo "
Your e-mail is send.
";
echo "
Thanks for sending an e-mail. You wil get an answer as ";
echo "soon as possible.
";
echo "
All your information is treated as confidential. ";
echo "Your e-mailadress will never be supplied to third parties.
";
}
?>