I would like my form (based on Swift Mailer) to redirect to a link by using header();
Problem is I just can't seem to find out where to place the header();
part so that the form is successfully sent and the person is redirect. This is the current code:
<?php
if(isset($_POST['email'])) {
// Require the Swift Mailer library
require_once 'lib/swift_required.php';
$transport = Swift_SmtpTransport::newInstance('smtp.gmail.com', 465, 'ssl' )
->setUsername('xxxx')
->setPassword('xxxx')
;
$mailer = Swift_Mailer::newInstance($transport);
foreach ($_POST as $key => $value)
$messageText .= ucfirst($key).": ".$value."\n\n";
$message = Swift_Message::newInstance('A message from Pivot Template Form')
->setFrom(array($_POST['email'] => $_POST['name']))
->setTo(array('email@email.com' => 'John Doe'))->setBody($messageText);
try{
echo($mailer->send($message));
}
catch(Exception $e){
echo($e->getMessage());
}
exit;
}
?>
Anybody have an idea as to where to add the line?