Hi, i have a normal search function in my site, and i want to save any searched words typed in the search box in a .txt file (like: search.txt). each word in a seperate line like this sample.txt -------------------------------------------- new cars how make money new cars etc. -------------------------------------------- This is my search form: <form onsubmit="search(src.value);return false;" id="searchform" method="get"> <input type="text" value="" id="s" name="src" /> <a onclick="document.getElementById('searchform').submit(); return false;" id="submit-search" href="#"><span>search</span></a> <input type="submit" name="submit" style="display: none;" value="search word"/> </form> Code (markup): by which php code can i save the searched words in this txt file?
<form method="get"> <input type="text" name="src"> <input type="submit" name="submit" value="Search"> </form> <?php if(isset($_REQUEST['submit']) && !empty($_REQUEST['src'])){ $fp = fopen('searched.txt',"a"); fwrite($fp,$_REQUEST['src']."\n"); } ?> PHP:
thx where should i paste this code? the search form is in a .tpl file. and it does not work when pasting in there should i create a seperate .php file? if yes how should i point it to the .tpl file?