File: D:/HostingSpaces/SBogers25/superbedrukt.nl/wwwroot/contactformVerzenden.php
<?php
include("all_kms_con.php");
$datum = date("d.m.y");
$tijd = date("H:i:s");
if(isset($_POST['secretcode'])){
$secretcode = $_POST['secretcode'];
if($secretcode == "spamcheckkomma"){
$valid_secretcode = true;
}else{
$valid_secretcode = false;
}
}else{
$valid_secretcode = false;
}
if(isset($_POST['naam'])){
$naam = $_POST['naam'];
}
if(isset($_POST['bericht'])){
$bericht = $_POST['bericht'];
}
if(isset($_POST['telefoon'])){
$telefoon = $_POST['telefoon'];
$telefoon = trim($telefoon);
$telefoon = str_replace("-","",$telefoon);
$telefoon = str_replace(" ","",$telefoon);
$telefoon = str_replace("+","00",$telefoon);
$valid_telefoon = true;
}else{
$valid_telefoon = false;
}
if(isset($_POST['email']) && !preg_match('/[\w-\.]+@([\w-]+\.)+[\w-]{2,4}/', $_POST['email'])){
$valid_emailadres = false;
$emailadres = $_POST['email'];
}else{
$valid_emailadres = true;
$emailadres = $_POST['email'];
}
if(!empty($naam) && $valid_telefoon && $valid_emailadres && !empty($bericht) && $valid_secretcode){
$datum = date("Y-m-d");
$tijd = date("H:i:s");
$datum = date_dutch($datum);
require_once 'css-js/phpmailer/class.phpmailer.php';
$bericht_klant = "\n
<body style=\"margin: 10px; background-color:#fff;\">
<style>
a{
color:#0066ff;
text-decoration:underline;
}
</style>
<div style=\"color:#636363; font-family:Verdana,Geneva,sans-serif; font-size:11px; line-height:18px; padding-bottom:23px; width: 800px;\">
<strong>Beste Susan,</strong><br><br>
Bij deze de gegevens van een persoon die het contactformulier op de website heeft ingevuld.<br>
Ingevuld op $datum om $tijd<br><br>
<strong>Contactgegevens: </strong><br>
Naam: 	 	 $naam<br>
Telefoonnummer: 	 $telefoon<br>
E-mailadres: 		 $emailadres<br>
Bericht: 		 $bericht<br><br>
Met vriendelijke groet,<br>
Komma Management System<br><br>
</div>
</body>";
$send_message = false;
$from = "info@superbedrukt.nl";
$from_naam = "Super Bedrukt";
$onderwerp = "Contactformulier website";
$mail = new PHPMailer(true); //defaults to using php "mail()"; the true param means it will throw exceptions on errors, which we need to catch
try {
$mail->AddReplyTo($from , $from_naam);
$mail->AddAddress($from, $from_naam);
$mail->SetFrom($from, $from_naam);
$mail->AddReplyTo($from, $from_naam);
$mail->Subject = $onderwerp;
$mail->MsgHTML($bericht_klant);
$mail->Send();
$send_message = true;
} catch (phpmailerException $e) {
$send_message = false;
echo $e->errorMessage(); //Pretty error messages from PHPMailer
} catch (Exception $e) {
$send_message = false;
echo $e->getMessage(); //Boring error messages from anything else!
}
if(!$send_message){
include("all_kms_con.php");
$naam = checkData($naam);
$telefoon = checkData($telefoon);
$bericht_klant = checkData($bericht_klant);
$datum = date("Y-m-d");
$tijd = date("H:i:s");
$q_log = "INSERT INTO kms_belme_log (naam, telefoonnummer, bericht, datum, tijd) VALUES ('$naam', '$telefoon', '$bericht_klant', '$datum', '$tijd')";
$r_log = mysql_query($q_log);
}
}?>