Processwire Form
<?php
// Process Form
if($input->post->submit) {
if($session->CSRF->hasValidToken()) {
// form submission is valid
// okay to process
// honeypot
$honeypot = $input->post->honeypot;
if(empty($honeypot)) {
// email
$email_to = "kreativan@outlook.com";
$email_subject = "Test Email";
$email_from = "example@email.com";
$email_body = "<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit...</p>";
// Include Template
// if you want to send email template jsut use $email_template instead of $email_body
ob_start();
include('email.php');
$email_template = ob_get_clean();
//Send email
$mail = wireMail();
$mail->to($email_to);
$mail->from($email_from);
$mail->subject($email_subject);
$mail->bodyHTML($email_body); // or $email_template
$mail->send();
}
} else {
// form submission is NOT valid
throw new WireException('CSRF check failed!');
}
// Reset token
$session->CSRF->resetToken();
}
?>
<form action="./" method="POST">
<?php echo $session->CSRF->renderInput(); ?>
<input class="uk-hidden" type="email" name="honeypot" />
<input type="submit" name="submit" value="Submit" >
</form>