I have a PHP file in which I send the actions with forms in which there are type hidden inputs with the variables that I need. But there comes a time when I need to reload the page and keep the variables of the $_POST
. Reloading is necessary to avoid form resubmission.
How could I do something like that? JavaScript maybe? or is there any way to do it with PHP?
You need to use
sesiones
to use global variables to your program, these will be common in all your files, persisting until you close the session.In this way you do not need to pass parameters through GET/POST, being able to redirect through
header()
without losing data stored in session variables.Or a PHP cookie :