| | I'd like to have a log of items entered into a search box on my site. How can I do this so it will write to a text file but not interfear with search operations? Thanks! [N]F |
|
|
QUOTE(nightfox @ Jan 24 2006, 11:20 PM) I'd like to have a log of items entered into a search box on my site. How can I do this so it will write to a text file but not interfear with search operations? Thanks! [N]F Depends on your script. Basically, the script that actually performs the search functions would need to be modified slightly. At the begining of that script, you would need to open your log file, write the vriable (search term) to it, close the log file then continue as normal. $_POST['search'] should be the the way to gather you search term. This means the post method form field named 'search'. You'll need to se the file system functions for PHP to open, modify, and close your log file. For a little more effort, I suggest a table in your mySQL database that can track the terms used as well as the number of times the term was searched for. Even better, break the search term up into seperate words (if a phrase was used) and add each word to the database and exclude common words like "the" "and" etc... I'd need to know how much PHP you knew before I'd really get into the modification with you. For me, the general directions above would be enough but many people simply don't know any PHP so the directions above wouldn't be enough. vujsa
Come on! That's so simple!
Just place it to your search.php file CODE <?php //$word is the word user inputs if($word) { $fp=fopen("words.txt", "a"); fwrite($fp, "$word|"); fclose($fp); } ?> As for counter of words: CODE <?php
$fp=fopen("words.txt", "r"); $words=""; while(!feof($fp)) { $words.=fread($fp, 1000); } $words=explode("|",$words); for(i=0;i<sizeof($words);i++) { $ma=0; $ch=$words[i]; for(j=0;j<sizeof($words);j++) { if($ch==$let[j]) { $ma++; break; } } if($ma==0) { printf("Word %s is searched",$ch); $searched=0; for(j=0;j<strlen(word);j++) { if($words[j]==$ch) { $searched++; } } printf("%d times",$searched); $let[$t]=$ch; $t++; } } ?>
Similar Topics
Keywords : logging items entered textbox
I recently got an idea for a project and one of the features I wanted the project to have was an I'm making a script that emails data and in the message box, I need all to be converted to \n Looking for logging, items, entered, textbox
|
|
![]() Logging Items Entered Into A Textbox |
| ADD REPLY / Got an Opinion! | a humble request :-) | RAPID SEARCH! | Free Hosting | [X] |
|
Express your Opinions, Thoughts or Contribute your information that might help someone here. Ask your Doubts & Queries to get answers.. "Together, We enlight each other!" |
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP. | 500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE |
|