Jump to content

Search and Back button


imi_99

Recommended Posts

Hello,

 

I have come across one major issue. I put search on my site and when i do search it shows the result. And when i click on details of any search result and it show the details.

 

But from here if i use back button then it dont show the previous search result again and comes up with page cannot be displayed with error message given below

 

"Click on the Refresh button on the toolbar to reload the page. After refreshing, you might need to navigate to the specific webpage again, or re-enter information. "

 

How can avoid this issue and how can i show search result again when click on back button from top of browser

 

Link to comment
Share on other sites

Please use search on this page as an example

 

http://www.whatahome.co.uk/

 

Suppose search for word "ls" it will show you some result. Then click on View details of any of result shown. After viewing details if you click back button from top it will not show you the previous searched result again. that is the issue.

 

Any further question please ask. thanks

Link to comment
Share on other sites

it asks if you want to repost the data, because it generated the previous page with a _POST

to fix this, do something like this ("proxy page")

for the search field:

//search page
<form method="POST" action="page1.php">
//rest of stuff here

 

for page1

<?php
$go = array();
$go .= $_POST['variable1'];
$go .= $_POST['variable2'];
//keep on this style until you have it all
$search_url = "search.php?".$go['0'];
$count = 1;
foreach($go as $value){
if ($value != 0){
$search_url .= "&var".$count."=".$value;
$count++;
}
}
header("location:".$search_url);
?>

and the final page, the search page:

<?php
//Search page: do your search by parsing through the $_GET vars
$var1 = addslashes($_GET['var1']);
$var2 = addslashes($_GET['var2']);
$var3 = addslashes($_GET['var3']);
//and so on.
//then add the $vars into your query
?>

**EDITED to add some security into the get variables

Link to comment
Share on other sites

Thanks for all of your help.

 

All solutions are fine but i got more easy solution which is to use get instead of post data in the form. I have implement in one of site and will change to all sites. Because all site having same issue. thanks again

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.