I want to execute a script and go back to the page where it is accessed from.

In other words:

pagex->pagey (the script) do something->go back to pagex

How to do it?

I am rewriting my dynamic links to directory type URLs, if it makes a difference.