Skip to content
Advertisement

Php refresh page with message? [closed]

I have an edit form with the url looking like localhost/edit-form/*code* The code is a random 16 long string. What I would like to do is when submitting the form, refresh the page showing the form again with the new values.

I have tried to redirect with an extra attribute like localhost/edit-form/*code*/message which returns an error saying page not found.

I have also tried something like localhost/edit-form/*code*?message=1 but message isnt available to get via $_GET.

My goal is just to have a div alert saying “form edited” after the page is refreshed.

Advertisement

Answer

Flash messages are usually stored in $_SESSION. You could create a custom method that…

  1. Stores the message to the session.
  2. Deletes the message from the session, as soon as it is displayed for the user.

You could then call the method in your template file as soon as the user is redirected to it.

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement