Hi,
first of all - thanks for Zenphoto - its a great piece of Software!
I like to Log the Users searches on my Zenphoto-Site. I made it the easy way and
added an SQL-Insert on the search.php which saves the searchwords and the number of pictures which were returned into a table.
My problem is that every time i search something and click on a result, the searchterm gets stored 2-3 times.
Maybe you know why this happens? Or do you know an more elegant way to implement a search-Log or have some tipps?
Thanks in advace
Comments
Each time the page gets loaded your code will be run. So, it will be run when page 1 is displayed, when page 2 is displayed, etc. You can test the page number and only record the search when page 1 is shown. That will reduce the number of times it gets stored. You could also come up with some sort of hash code for a particular search based on the IP address and whatever else you might find that indicate it is a unique search. Then you could see if the hash already existed and not store if it does.
thanks for you answer. I see that putting the code in the search.php is not the best solution. I also have the problem that i also get all the clicks on tags as search-requests. But i am only interrested in the real search-requests entered by the users so i can improve my gallerys over time.
So it will be better to catch the data entered into the search-textfield and write it to the db. But i dont know how to catch the data because the action of the search form is /page/search.
Do you know a way how i can accomplish this task?
Thanks a lot in advance!
One advantage of this is that you only get the "POST" on the initial page, the clicks on next/previous pages all use query parameters.
thanks a lot for your time for helping me. I tried it the way you wrote but it doesnt work for me. It doesnt matter where i place the following code:
`
if (isset($_POST['searchwords'])){
echo "
real search
";}else {echo "click on tags"; }
?>
`
I always get a "click on tags"?
Thanks a lot for your help and for investing so much time in developing zenphoto!