Return to the search results. (PHP)?

Don't want to reinvent the wheel, but really the solution didn't work. in the network. So until I write, I would like to ask japanesemade.

You have a database, say, cars. According to the search request, consisting of about 4-5 fields, we derive a list of results, then go to the 4th page in the search results. In the end in the URL we get something like this:¶m1=21¶m2=...

On this page we find what we need, and move on viewing this object:

On the preview page of this object, it is necessary to perform, such as sending requests using the form on this object. Ie to reload the page again.

Hence the question:

How to implement a more correct return to the search results, i.e. pulling yourself constantly in the URL string:


Moreover, can constantly change the search parameters added-removed, and the preparation and pulling a these parameters are somehow not very convenient. So far the only option I see is writing a layer that will handle any incoming URL request and constantly pass it on. But somehow it's not very nice...
October 14th 19 at 11:49
13 answers
October 14th 19 at 11:51
cookies ||
session ||
Cookies, sessions... For each page separately?.. )
Open 5-6 pages with different search pages, a cook or a session variable one... except that for each search to sozdavat and pass each time a variable with outcomes for the thread pages... - dedric.Carro commented on October 14th 19 at 11:54
>session variable one

have I missed something ??? why session variable one ???? within your session, create a few, what's the problem ??? - Rusty.Runolfsson commented on October 14th 19 at 11:57
I think he meant that one browser's bookmarks will work as part of a General session and in the overall of the cookies. It just should be divided so that each tab in the browser will store your search string. - Emmanuelle_Dooley78 commented on October 14th 19 at 12:00
October 14th 19 at 11:53
Remember in the session settings so that they can be later retrieved by numeric key, and the key pulled by

$_SESSION['search_history'] = array(
1 => "?page=4¶m1=21¶m2=33¶m3=13&...¶m44=123"
, 2 => "another search"

If you need to return to the search page, simply retrieved from an array by key value.
October 14th 19 at 11:55
but if one were to record the search parameters in a cookie? and later process them
October 14th 19 at 11:57
Session, cookie?
Above I write that it is not suitable, since in the same session can be N number of search results. - dedric.Carro commented on October 14th 19 at 12:00
October 14th 19 at 11:59
>Above unsubscribed that it is not suitable, since in the same session can be N number of search results

Session IMHO the best option. and what hinders to store in session an array (hash) with the search results ?? or if not you need to keep a variable and with each change search query just grind it ???
October 14th 19 at 12:01
1. to take "?page=4¶m1=21¶m2=33¶m3=13&...¶m44=123"
2. pass through a base64
3. to cram into a hidden field in the page
4. ...
5. Profit!
October 14th 19 at 12:03
The only thing that came to mind in terms of separate tabs of a single browser's SessionStorage. But this is JS and his hands. And not all working yet.
October 14th 19 at 12:05
What if to keep it all in a hidden form field order? And take the value from the Referer?
October 14th 19 at 12:07
you can use AJAX to pass parameters through POST
October 14th 19 at 12:09
Your usecase described the situation when is better to use AJAX to submit and return to the search through js:window.history
October 14th 19 at 12:11
Options with AJAX disappear immediately for it is not kosher, as it needs to work with mobile browsers, and they do not all support;
Version with different queries in the session the most interesting, and I thought about it, but still, with some paranoia, decided that this is no longer, as can be presumably open 20-30 Windows search and then will fly beyond the constraints of the session (if not a simple site), but I wanted some versatility...
Thanks for the replies, but so far I have not seen any acceptable solution.
Can't believe nobody thought about the gap some.
October 14th 19 at 12:13
Handler search generates the resultant set of records, stores them (in whole or id) in the session key (to save and query parameters, for example md5 of the search and redirects to something like /search?key=hash — on history you can go for some time and database load less
Well, this is the most sensible solution, but again, through a Session... Is there no other options... :( - dedric.Carro commented on October 14th 19 at 12:16
October 14th 19 at 12:15
that is, your form is processed the same page? or there is an appeal to another and then redirect back?
although this is not so important, but if redirected, there is not comme Il faut work.

in your form on product.php (for example) the item to be added <|input type="hidden" name="ref" value="$_SERVER['HTTP_REFERER']"|>
if processing the same page, then send all post-ohms, then put a reference <|a href=$_POST['ref']|>to the search results<|/a|>
(sticks clear is that the parser ate)

if there is perenapravlenie, then send all of the post, and on the redirection set
header("Location: product.php?ref=$_POST['ref']" );
on product.php put the link <|a href=$_GET['ref']|>to the search results<|/a|>

but that crutches generally this is done via session, but with them I can't help you :( - dedric.Carro commented on October 14th 19 at 12:18
That's exactly what it is purely through the crutches, but wanted the good decisions... most Likely will have to do through session, to decide as it is a clean and nice solution... we just Need to check how many sessions you can store data - Rusty.Runolfsson commented on October 14th 19 at 12:21
Then again... how to control the deletion of the session... No... this is incorrect... - Emmanuelle_Dooley78 commented on October 14th 19 at 12:24
As for example open in one session 40-50-60 searches, some closed, some new ones are created... and the session is not unlimited... And if instead of sessions to use the database, even though NoSQL, it's all comic to do it with... No... still we need something more original to find or implement... - dedric.Carro commented on October 14th 19 at 12:27
then write the search results to a file, assign it a name from a random set of digits, and then carry with them this hash, for example from the results of productu just using get — product.php?search_result_file_number=cedcd154d81cvszFRv1sdf156481cd, then the same through the form, but then you have to change a little bit, and the output of search - dedric.Carro commented on October 14th 19 at 12:30
Same as NoSQL, or storage in a database or in Sessions )
Damn, I get it... will have to write all the same a separate layer that would automatically disassemble and assemble Query String would be... all other options as-is from the evil one... ))) - Joan.Nicol commented on October 14th 19 at 12:33

Find more questions by tags PHP