Strange back button problem

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Andrew275
Forum Newbie
Posts: 4
Joined: Sat Oct 05, 2002 3:09 pm

Strange back button problem

Post 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?
User avatar
Takuma
Forum Regular
Posts: 931
Joined: Sun Aug 04, 2002 10:24 am
Location: UK
Contact:

Post 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...
Andrew275
Forum Newbie
Posts: 4
Joined: Sat Oct 05, 2002 3:09 pm

Post 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).
User avatar
Takuma
Forum Regular
Posts: 931
Joined: Sun Aug 04, 2002 10:24 am
Location: UK
Contact:

Post by Takuma »

What does header.php do?
Andrew275
Forum Newbie
Posts: 4
Joined: Sat Oct 05, 2002 3:09 pm

Post by Andrew275 »

Updates a table and does a few template evals.
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post 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
Andrew275
Forum Newbie
Posts: 4
Joined: Sat Oct 05, 2002 3:09 pm

Post 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.
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post 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
Post Reply