De PHP code is als volgt (heb dit nu zo in een UDT geplakt)
// geef e-mail adres op van ontvanger
$mail_ontv = "
mail@website.nl";
// 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['voornaam'] || !$_POST['mail'] || !checkmail($_POST['mail']) ))
{
if ($_POST['submit'] && (!$_POST['voornaam'] || !$_POST['mail'] || !checkmail($_POST['mail']) ))
{
echo "Niet alle gegevens zijn volledig ingevuld.Controleer of alle velden zijn ingevuld en probeerhet formulier opnieuw te verzenden.";
}
// form + tabel
echo "";
echo "";
// voornaam
echo "Mijn naam:";
echo "";
// achternaam
//echo "Achternaam:";
//echo "";
// adres en huisnummer
//echo "Adres en huisnummer: ";
//echo "";
// postcode
//echo "Postcode:";
//echo "";
// plaats
// echo "Plaats:";
// echo "";
// mail
echo "Mijn e-mail:";
echo "";
// mail
//echo "Mijn vraag/idee:";
///echo "";
// mail
//echo "Aantal:";
//echo "";
//mail
echo "Mijn vraag/idee:";
echo "" . htmlentities($_POST['msggs']) . "";
//space
echo " ";
// button
echo " ";
echo "";
// sluit form + tabel
echo "";
echo "";
}
// versturen naar
else
{
// set datum
$datum = date("d.m.Y H:i");
// set ip
$ip = $_SERVER['REMOTE_ADDR'];
$inhoud_mail = "=============================================\n";
$inhoud_mail .= "Donderbellen idee/vraag (contact via website)\n";
$inhoud_mail .= "============================================\n\n";
$inhoud_mail .= $_SERVER['SCRIPT_URI'] . "\n\n";
$inhoud_mail .= "Zijn/haar naam: " . $_POST['voornaam'] . "\n";
//$inhoud_mail .= "Achternaam: " . $_POST['achternaam'] . "\n";
//$inhoud_mail .= "Adres en huisnummer: " . $_POST['adres'] . "\n";
//$inhoud_mail .= "Postcode: " . $_POST['postcode'] . "\n";
//$inhoud_mail .= "Plaats: " . $_POST['plaats'] . "\n";
$inhoud_mail .= "Zijn/haar e-mail adres: " . $_POST['mail'] . "\n";
$inhoud_mail .= "Zijn/haar vraag en/of idee: " . $_POST['msggs'] . "\n\n";
$inhoud_mail .= "Verstuurd op " . $datum . " via het ip " . $ip . "\n\n";
$inhoud_mail .= "===================================================\n\n";
// --------------------
// spambot protectie
// ------
// van de tutorial:
http://www.phphulp.nl/php/tutorials/10/340/
// ------
$headers = "From: " . $_POST['voornaam'] . " ";
$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['voornaam'] = str_replace("\n", "", $_POST['voornaam']); // Verwijder \n
$_POST['voornaam'] = str_replace("\r", "", $_POST['voornaam']); // Verwijder \r
$_POST['voornaam'] = str_replace("\"", "\\\"", str_replace("\\", "\\\\", $_POST['voornaam'])); // Slashes van quotes
mail($mail_ontv, $_POST['voornaam'], $inhoud_mail, $headers);
echo "Je vraag/idee is goed verzonden!";
echo "Je ontvangt zo snel mogelijk een reactie.";
}