douxidao3524 2013-07-27 14:30
浏览 49
已采纳

在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');
        }
    });
});

This sends results to the specified email address correctly but remains on the '/sendmail' page.

  • 写回答

1条回答 默认 最新

  • dqppv86022 2013-07-27 15:01
    关注

    Have you tried:

    return Redirect::back()->with('success', 'You have posted successfully');
    

    ?

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 树莓派与pix飞控通信
  • ¥15 自动转发微信群信息到另外一个微信群
  • ¥15 outlook无法配置成功
  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题