Save Last Query

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
User avatar
shiznatix
DevNet Master
Posts: 2745
Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:

Save Last Query

Post by shiznatix »

I have a search thing but I want registered users to be able to 'save their search' so they can sign in later and re-run that search without filling out a massive forum each time.

What I am doing now is whenever they run a search it saves the sql in a session then gives a link saying 'remember this search' and when you follow that it saved the sql in a database.

I am not sure I like this way of doing it because they could just run a search and then go to another section of the page then type in the SaveSearch.php and it will save the last search they did.

Although this is not really horrible it does give the user the ability to control the site in a way i don't want them to.

So my question is: what would be the best way to have a 'save this search' feature?
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Post by Benjamin »

I store it (the search query) in the database before it gets executed the first time. Anytime they visit the results page, if no data is posted, it pulls the last query they made back out of the database.
Post Reply