I have a page where users submit a form, and it goes to a separate PHP script. After the script is done, it header() redirects the user back to the page they were on. Now what I want to do is if there is an error or certain conditions in the script, redirect the user to the same page but display a Javascript alert once they get there as a warning message. I could append some variables to the URL and check for that with $_GET but I figure there is probably an easier way… perhaps with some POST data, or something like that?
Thanks
I have a page where users submit a form, and it goes to a
Share
If an error is encountered, store the error state to a $_SESSION array and then redirect the browser to the original page. Have a script on the original page to check if an error state is set. If yes, trigger a javascript alert or whatever handling you want to have.
And at the common footer template (or at the footer of original page), check and clear the errors array, so it doesn’t persist when the user moves to other pages or reloads the current page.
Example:
processor.phporiginalpage.phpHope that helps.