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
https://forums.phpfreaks.com/topic/101454-search-and-back-button/
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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.