I am trying to work with https://github.com/jackilyn/bootstrap-contact/ to add a bootstrap contact form to my codeigniter project.
The form is submitted as follows:
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>" id="contactform">
after submission and validation, the following code is used to email the contact info:
//If there is no error, send the email
if(!isset($hasError)) {
$emailTo = 'you@yourwebsite.com'; // Put your own email address here
$body = "Name: $name \n\nEmail: $email \n\nPhone Number: $phone \n\nSubject: $subject \n\nComments:\n $comments";
$headers = 'From: My Site <'.$emailTo.'>' . "\r\n" . 'Reply-To: ' . $email;
mail($emailTo, $subject, $body, $headers);
$emailSent = true;
}
I don't like the way the php code is included in the page itself and would like to move it to a seperate controller for security. How can I manage the program flow so that after the form is submitted with no errors , the flow is directed to a controller so I can execute the emailing code there instead , while keeping the form pointing to itself?
Thanks in advance,
Bill