Re: Going back with multiple submits to the same page

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



At 1/15/2007 01:52 PM, Otto Wyss wrote:
When values are entered on one of my page I submit the result back to the same page (form action=same_page). Unfortunately each submit adds an entry into the history, so history back doesn't work in a single step. Yet if the count of submits were known I could use goto(n). What's the best way to get this count? PHP or Javascript?


What you're suggesting doesn't sound easy.

If you're going to programmatically take the user to a previous page, say for example if they click a form button within your page, then using JavaScript you could simply walk backward through the window.history() array until you came to an URL that doesn't match with the current page. Of course such a solution would break if JavaScript were disabled so you'd need to build a redundant system server-side to make sure your site didn't break.

Only JavaScript is aware of the window.history() array, but I don't believe JavaScript can detect when the back button is activated. You can test for window.onunload, but that doesn't tell you which "direction" the user is headed -- forward, backward, sideways, or same page reload.

In a cacheing system the browser might not even make a server hit when going back. If you can take your computer off-line and still walk backward in browser history, your problem complicates.

Of course PHP isn't naturally aware of browser history but you could store in the session or cookie the name of the last page in the current session that wasn't the current page. You'd also need to set flags in each iteration of a page so that PHP could determine whether the page being requested had already been downloaded.

What happens when the user simply wants to reload the current page? It sounds messy. Perhaps, rather than interfering with the normal functioning of the browser, you could simply let it do its thing and take steps server-side to prevent the user from re-submitting the current form or whatever your goal is.

Good luck,

Paul
__________________________

Juniper Webcraft Ltd.
http://juniperwebcraft.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux