简体   繁体   中英

How can I print out session message in Laravel?

I'm trying to print out my session/flash message to my user(s) as feedback.

I couldn't get it to display, worse than that, it give me the error.

在此处输入图片说明


view

{{-- Flash Message --}}
@if($success_register)
@if ($message = Session::get('success_register'))
<div class="alert alert-block alert-success">
  <i class=" fa fa-check cool-green "></i>
  {{ nl2br($message) }}
</div>
@endif
@endif

controller

return Redirect::to('/')
    ->with('success_register',' Your Account has been created ! <small> Email has been sent to set-password, and activation.</small>');

  • What did I do wrong here ?
  • Is there a better way to print them out ?
  • Can someone please correct me ?

You should use Session::get('success_register') on both occassions simply said!

@if(Session::has('success_register'))
    <div class="alert alert-block alert-success">
        <i class=" fa fa-check cool-green "></i>
        {{ nl2br(Session::get('success_register')) }}
    </div>
@endif

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM