Send email
$data = @$_POST;
$err = array();
if(!empty($_POST)){
if(empty($_POST["your_name"])){
$err["your_name"] = true;
}
if(empty($_POST["your_email"])){
$err["your_email"] = true;
}
if(empty($_POST["your_subject"])){
$err["your_subject"] = true;
}
if(empty($_POST["your_message"])){
$err["your_message"] = true;
}
if(empty($err)){
$your_name = strip_tags($_POST["your_name"]);
$your_company = strip_tags($_POST["your_company"]);
$your_phone = strip_tags($_POST["your_phone"]);
$your_email = strip_tags($_POST["your_email"]);
$your_subject = strip_tags($_POST["your_subject"]);
$your_message = strip_tags($_POST["your_message"]);
$caption = "Contactform";
$admin_email = get_option("admin_email");
ob_start();
include("template-contact-mail.php");
$mail_content = ob_get_contents();
ob_end_clean() ;
$headers = 'Content-Type: text/html; charset=UTF-8'.'\r\n';
$headers .= 'From: '.$your_name.' <'.$your_email.'>' . "\r\n";
$success = wp_mail($admin_email, $caption, $mail_content, $headers);
header("Location: ".get_permalink(PAGE_ID_SUCCESS_CONTACT)); die;
}
}
<form action="" method="post" class="wpcf7-form">
<p<?php if(!empty($err["your_name"])): ?> class="err"<?php endif; ?>>
<label><?php _e("Your name") ?> (*):</label>
<span class="wpcf7-form-control-wrap"><input type="text" name="your_name" value="<?php echo $data["your_name"] ?>" size="40" class="wpcf7-form-control wpcf7-text" /></span>
</p>
<p<?php if(!empty($err["your_company"])): ?> class="err"<?php endif; ?>>
<label><?php _e("Company") ?>:</label>
<span class="wpcf7-form-control-wrap"><input type="text" name="your_company" value="<?php echo $data["your_company"] ?>" size="40" class="wpcf7-form-control wpcf7-text" /></span>
</p>
<p<?php if(!empty($err["your_phone"])): ?> class="err"<?php endif; ?>>
<label><?php _e("Phone") ?>:</label>
<span class="wpcf7-form-control-wrap"><input type="text" name="your_phone" value="<?php echo $data["your_phone"] ?>" size="40" class="wpcf7-form-control wpcf7-text" /></span>
</p>
<p<?php if(!empty($err["your_email"])): ?> class="err"<?php endif; ?>>
<label><?php _e("Email") ?> (*):</label>
<span class="wpcf7-form-control-wrap"><input type="email" name="your_email" value="<?php echo $data["your_email"] ?>" size="40" class="wpcf7-form-control wpcf7-text" /></span>
</p>
<p<?php if(!empty($err["your_subject"])): ?> class="err"<?php endif; ?>>
<label><?php _e("Subject") ?> (*):</label>
<span class="wpcf7-form-control-wrap"><input type="text" name="your_subject" value="<?php echo $data["your_subject"] ?>" size="40" class="wpcf7-form-control wpcf7-text" /></span>
</p>
<p<?php if(!empty($err["your_message"])): ?> class="err"<?php endif; ?>>
<label><?php _e("Message") ?> (*):</label>
<span class="wpcf7-form-control-wrap"><textarea name="your_message" cols="40" rows="10" class="wpcf7-form-control wpcf7-textarea"><?php echo $data["your_message"] ?></textarea></span>
</p>
<p>
<input type="submit" value="submit" class="wpcf7-form-control wpcf7-submit" />
</p>
</form>
template-contact-mail.php
<br />Onderwerp: <?php echo $caption ?> <br /> <br />NAME: <br /><?php echo $your_name ?> <br /> <br />COMPANY: <br /><?php echo $your_company ?> <br /> <br />PHONE: <br /><?php echo $your_phone ?> <br /> <br />E-MAIL ADDRESS: <br /><?php echo $your_email ?> <br /> <br />SUBJECT: <br /><?php echo $your_subject ?> <br /> <br />MESSAGE: <br /><?php echo $your_message ?> <br /> <br />-- <br />atanasfilipov.com


