Search code examples
javascriptbuttonexecutionback

Go back 1 history but DONT run any query or whatever


This is a pretty nice script to go back 1 history:

<INPUT TYPE="button" VALUE="Back" onClick="history.go(-1);>

But the problem is, if I executed any query or whatever on let's say addnewcustomer.php and than I link to companyview.php and using this code I go back to addnewcustomer.php, it executes the same query all over (or browser gives me a warning and have to hit F5). How to avoid this?

Thanks in advance.


Solution

  • The best way to avoid these situations would be to:

    1. not change any data on GET requests, instead manipulate only on POST requests.
    2. implement post-to-get (303) redirect after any data manipulation.

    You should then be good