在laravel 4中提交表单后重定向到联系人页面 [英] Redirect to contacts page after submitting form in laravel 4
本文介绍了在laravel 4中提交表单后重定向到联系人页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
一旦我提交了详细信息,我想重定向回到联系人页面.我在论坛上查看了解决方案,但找不到解决方案.
I would like to redirect back to the contacts page once I have submitted my details. I have looked on solutions from the forums but I cannot get a solution.
到目前为止,这就是我所拥有的:
So far this is what I have:
Route::post('sendmail', function()
{
Mail::send('emails.auth.mail', array('token'=>'SAMPLE'), function($message){
$message = Swift_Message::newInstance();
$email = $_POST['email']; $name = $_POST['name'];
$message->setFrom(array($email => $name));
$message->setTo(array('name@name.com' => 'Jim Scott'));
$subject = $_POST['subject'];
$message->setSubject($subject);
$msg = $_POST['msg'];
$message->setBody($msg);
$transport = Swift_SmtpTransport::newInstance('smtp.gmail.com', 465, 'ssl')->setUsername('username')->setPassword('pass');
$transport->setLocalDomain('[127.0.0.1]');
$mailer = Swift_Mailer::newInstance($transport);
$result = $mailer->send($message);
if($result) {
return Redirect::to(URL::previous())->with('success', 'You have posted successfully');
}
});
});
这会将结果正确发送到指定的电子邮件地址,但仍保留在"/sendmail"页面上.
This sends results to the specified email address correctly but remains on the '/sendmail' page.
推荐答案
您是否尝试过:
return Redirect::back()->with('success', 'You have posted successfully');
?
这篇关于在laravel 4中提交表单后重定向到联系人页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文