php - Displaying Message After Redirecting -
what best way display success message after submitting form , redirecting.
i'm developing script smarty template engine , don't want use javascript want easy possible user design or own template , have tried using sessions display message seems unset after redirecting example
the form
<form action="" id="comment_form" method="post"> <input type="hidden" name="movie_id" id="page_id" value="{$mov.mid}" /> <input type="hidden" name="user_id" id="user_id" value="{$logged_id}" /> <input class="span2" name="comment" type="text" /> <button class="btn" name="add_comment" type="submit">add comment</button> </form>
php
if (isset($_post['add_comment'])) { if (!empty($_post['comment'])) { $user_id = $logged_id; $post_comment = mysqli_real_escape_string($con, $_post['comment']); $movie->addmoviecomments($con, $movie_id, $user_id, $post_comment); $_session['insert'] = 'success'; header ('location: '.$_server['request_uri']); } else { $_session['insert'] = 'empty'; } }
now trying display success in tpl
{if isset($smarty.session.insert)} <div class="alert alert-success"> <button type="button" class="close" data-dismiss="alert">×</button> <h4>success</h4> comment added </div> {/if} {php}unset($_session['insert']);{/php}
so can me out , tell me best way or tell me why unset before displayed.
try
if( isset($_session['insert']) && $_session['insert'] == 'success') { //your alert unset($_session['insert']); }
Comments
Post a Comment