Page 1 of 1

Strange back button problem

Posted: Sat Oct 05, 2002 3:09 pm
by Andrew275
On my development site: http://beta.deluxeportal.com/index.php I'm having some strange problems with the back button...

For example, if you try posting and leave out a message, you get an error. You can press back to return to the posting page. This is how it works on most pages, and this is what I want. However, on a very select number of pages (the login page, and the search page), if you get the error message and press back, you still get the screen with the error message. Then, the next time you press back, you are completely taken out of the page.

I haven't been able to figure this out, as I can't see anything that makes those pages different from the others. Any suggestions/idea?

Posted: Sun Oct 06, 2002 3:00 am
by Takuma
Do you use anything special in those pages, e.g. sessions. And could we have a look at the code... This could not be anything to do with PHP, it might be bug of the browser...

Posted: Sun Oct 06, 2002 9:16 am
by Andrew275
I didn't use PHP's session management features until recently, but the problem occured before I used them.

There's a lot of code, but here is the basic layout of it:

Code: Select all

<?php
require('function.php');

if ($op=='post')
{
   if ($problem)
   {
      require('header.php');
      eval("\$template = "".get_template('error')."";");
      display_template($template);
   }
   ...
}
else
{
   require('header.php');
   eval("\$template = "".get_template('index')."";");
   display_template($template);
}
?>
Now that I think about it, this only happens on some servers. On my home server, it behaves as it should, but on some servers, it has problems with these very few pages. Maybe there's some PHP or Apache setting that's causing this. (Both servers are using PHP 4.2.x).

Posted: Sun Oct 06, 2002 10:50 am
by Takuma
What does header.php do?

Posted: Sun Oct 06, 2002 4:35 pm
by Andrew275
Updates a table and does a few template evals.

Posted: Mon Oct 07, 2002 1:59 am
by twigletmac
It could be that the $op variable is still set when you return to the page using the back button so it gives you the error again. The back button is not the best way to return someone to a form, have you considered saving the information they entered and using if statements to show posted data in the form if it exists or nothing if it doesn't?

Mac

Posted: Mon Oct 07, 2002 3:53 pm
by Andrew275
$op isn't still set, and in fact if you refresh after going back, it loads the correct page. I tried adding no cache headers, but to no avail.

Posted: Tue Oct 08, 2002 2:23 am
by twigletmac
The back button is still not the best method of sending someone back to a form when you need them to make adjustments to what they have typed. Have you considered including the form into the processing page when an error is returned, using the values from the $_POST array to populate the fields and letting the users make the changes (which you can highlight better) without having to worry what happens when they press the back button on their browser?

Mac