{source}
<!– BEGIN MAILFORM –>
<?php
if(isset($_POST[‘submitcontactform’])) {
// EDIT THE LINES BELOW AS REQUIRED
//$email_to = “bart@bramblestorm-solutions.com”;
$email_to = “info@americanclay.nl”;
//$email_to = “bart.blommers@gmail.com”;
$email_cc = “bart.blommers@gmail.com”;
$email_subject = “Aanmelding stukadoorsdag mei 2017”;
function died($error) {
// your error code can go here
print ‘<script type=”text/javascript”>’;
print ‘alert(“Onze excuses, het formulier is niet correct ingevuld.\n\n’. $error .'”);’;
print ‘history.back();</script>’;
// echo “We are very sorry, but there were error(s) found with the form you submitted. “;
// echo “These errors appear below.<br /><br />”;
// echo $error.”<br /><br />”;
// echo “Please go back and fix these errors.<br /><br />”;
die();
}
// validation expected data exists
if(!isset($_POST[‘name’]) || !isset($_POST[‘mail’]) || !isset($_POST[‘phone’]))
{
died(‘<h1>Onze excuses…</h1>Er lijkt iets niet goed te gaan. Probeer het nog eens.’);
}
$name = $_POST[‘name’]; // required
$email_from = $_POST[‘mail’]; // required
$phone = $_POST[‘phone’]; // required
$bedrijfsnaam = $_POST[‘bedrijfsnaam’]; // not required
$aant_deelnemers = $_POST[‘aant_deelnemers’]; // not required
$remarks = “”; // not required
$newsletter = $_POST[‘newsletter’]; // not required
$error_message = “”;
$string_exp = “/^[A-Za-z .’-]+$/”;
if(!preg_match($string_exp,$name))
{
$error_message .= ‘- The name does not appear to be valid.\n’;
}
$email_exp = ‘/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/’;
if(!preg_match($email_exp,$email_from))
{
$error_message .= ‘- The emailaddress does not appear to be valid.\n’;
}
// if(strlen($phone) == 0)
// {
// $error_message .= ‘- The phonenumber does not appear to be valid.\n’;
// }
if(strlen($error_message) > 0)
{
died($error_message);
}
$email_message = “Form details below.\n\n”;
function clean_string($string)
{
$bad = array(“content-type”,”bcc:”,”to:”,”cc:”,”href”);
return str_replace($bad,””,$string);
}
$email_message .= “Name: “.clean_string($name).”\n”;
$email_message .= “Email: “.clean_string($email_from).”\n”;
$email_message .= “Phone: “.clean_string($phone).”\n\n”;
$email_message .= “bedrijfsnaam: “.clean_string($bedrijfsnaam).”\n”;
$email_message .= “Aantal deelnemers: “.clean_string($aant_deelnemers).”\n\n”;
$email_message .= “Newsletter: “.clean_string($newsletter).”\n”;
function saveToDb($name,$email_from,$phone,$bedrijfsnaam,$aant_deelnemers,$remarks,$newsletter)
{
include(‘dbconn.php’);
if($newsletter==””){
$newsletter=”off”;
}
$name= mysql_real_escape_string($name);
$email_from= mysql_real_escape_string($email_from);
$phone= mysql_real_escape_string($phone);
$bedrijfsnaam = mysql_real_escape_string($bedrijfsnaam);
$aant_deelnemers= mysql_real_escape_string($aant_deelnemers);
$newsletter = mysql_real_escape_string($newsletter);
$sql = ” INSERT INTO
`webform_contact`
(`naam`,`emailadres`,`telefoonnummer`,`onderwerp`,`type_project`,`opmerkingen`,`nieuwsbrief`)
VALUES
(‘$name’,’$email_from’,’$phone’,’$bedrijfsnaam’,’$aant_deelnemers’,’$remarks’,’$newsletter’)
“;
mysql_query($sql) or die(mysql_error());
}
saveToDb($name,$email_from,$phone,$bedrijfsnaam,$aant_deelnemers,$remarks,$newsletter);
// create email headers
$headers = ‘From: ‘.$email_from.”\r\n”.
‘Cc: ‘.$email_cc.”\r\n”.
//’Bcc: ‘.$email_bcc.”\r\n”.
‘Reply-To: ‘.$email_from.”\r\n” .
‘X-Mailer: PHP/’ . phpversion();
//@mail($email_to, $email_subject, $email_message, $headers);
mail($email_to, $email_subject, $email_message, $headers);
?>
<!– include your own success html here –>
<h1>Bedankt voor uw aanmelding!</h1>
<p>
Bedankt voor uw aanmelding voor de stukadoorsdag van American Clay!<br>
We nemen spoedig contact met u op.
</p>
<br>
<br>
<!– <a href=”” class=”acn-button” onClick=”window.close();”>Sluit dit venster</a> –>
<?php
} else {
?>
<a name=”contactform_anchor”></a><form id=”contactform” method=”POST” action=”<?php echo htmlentities($_SERVER[‘PHP_SELF’]); ?>”>
<h1>Aanmelden stukadoorsdag</h1>
<p>Naam:<sup>*</sup><br>
<input type=”text” id=”name” name=”name” style=”border-top-left-radius: 2px 2px; border-top-right-radius: 2px 2px; border-bottom-right-radius: 2px 2px; border-bottom-left-radius: 2px 2px; margin-right: auto; margin-left: auto; width: 100%;”>
</p>
<p>Emailadres:<sup>*</sup><br>
<input type=”email” id=”mail” name=”mail” style=”border-top-left-radius: 2px 2px; border-top-right-radius: 2px 2px; border-bottom-right-radius: 2px 2px; border-bottom-left-radius: 2px 2px; margin-right: auto; margin-left: auto; width: 100%;”><br>
</p>
<p>Telefoonnummer:<sup>*</sup><br>
<input type=”text” id=”phone” name=”phone” style=”border-top-left-radius: 2px 2px; border-top-right-radius: 2px 2px; border-bottom-right-radius: 2px 2px; border-bottom-left-radius: 2px 2px; margin-right: auto; margin-left: auto; width: 100%;”><br>
</p>
<p>Bedrijfsnaam:<br>
<input type=”text” id=”bedrijfsnaam” name=”bedrijfsnaam” style=”border-top-left-radius: 2px 2px; border-top-right-radius: 2px 2px; border-bottom-right-radius: 2px 2px; border-bottom-left-radius: 2px 2px; margin-right: auto; margin-left: auto; width: 100%;”><br>
</p>
<p>Aantal deelnemers:<br>
<input type=”text” id=”aant_deelnemers” name=”aant_deelnemers” style=”border-top-left-radius: 2px 2px; border-top-right-radius: 2px 2px; border-bottom-right-radius: 2px 2px; border-bottom-left-radius: 2px 2px; margin-right: auto; margin-left: auto; width: 100%;”>
</p>
<!–<p>Vragen of opmerkingen:<br>
<textarea id=”remarks” name=”remarks” style=”border-top-left-radius: 2px 2px; border-top-right-radius: 2px 2px; border-bottom-right-radius: 2px 2px; border-bottom-left-radius: 2px 2px; margin-right: auto; margin-left: auto; width: 100%; height: 150px;”>
</textarea><br>
</p>–>
<p>
<label class=”art-checkbox”>
<input type=”checkbox” id=”newsletter” name=”newsletter” >Ik wil graag nieuwsbrieven van American Clay ontvangen
</label><br>
</p>
<p style=”text-align: left;”>
<input type=”submit” id=”submitcontactform” name=”submitcontactform” class=”button” value=”Send”><br>
</p>
<p><br></p>
</form>
<?php
}
?>
<!– END MAILFORM –>
{/source}