php - Redirect after post to the same page, but display a "Success" message -
recently found out scheme of post/redirect flawed, , see no alternatives prepare it. consider step step scenario, has work without javascript/ajax:
admin goes forum page, browses specific thread. he deletes thread. the scheme sends deletion request deletepost.php after form processed, deletepost.php shows "thread deleted page", , header refresh after few seconds original thread page.because refreshing same page (either html head tag, or header(refresh:time, url=url), when user presses f5 "confirm form resubmission" message.
i can't find alternative me out of situation asks resubmit form. here alternatives , why flawed:
do non refresh php header() redirection. form resubmission gone, can't show user "success" message, makes strange.
append ?success var when redirecting same page. works because redirected new page. if user hits f5, success var remain there forever. also, if user decides moderate again, redirected same page same var, making form resubmission happen on again.
save on session variable successful message, , load on redirected page, timed refresh redirection original page. problem session flash messages unreliable when user moderating many tabs @ once. messages different pages not know tab belong to. people don't utilize cookies no messages well.
is there elegant way out of without relying on javascript?
i prefer thought of storing flash messages in session.
$_session[messages][$id] = array( 'type' => 'success', 'content' => 'deleted. )
the id threads id.
php url-redirection html-form-post
No comments:
Post a Comment