Logging Items Entered Into A Textbox

free web hosting
Free Web Hosting > Computers & Tech > Programming > Scripting > PHP

Logging Items Entered Into A Textbox

nightfox
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

Reply

vujsa
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'. smile.gif

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

 

 

 


Reply

CrazyPensil
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++;
    }
  }
?>

Reply


Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.

Similar Topics

Keywords : logging items entered textbox

  1. Changing A Value From A Textbox - or something. don't exactly how to explain. (6)
  2. Making A Value In A Textbox Stay - (4)
    Hey! I know it is possible, but I don't know how to do it. Anyone who know how I can make the
    following: When a user type a message, and press Send, he will come to a page that will check the
    message. If an Error occur, the user must press a button, that will take him back to the message,
    and fix the error. but The problem is, that when the user press the button, his message is gone, and
    he must write it again. bad luck, if the message was long. Hope You undertsand what I want
    /smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" /> Tha...
  3. Automated Product Suggestion Script - Compare user lists and suggest related items based on pattern matching (2)
    I recently got an idea for a project and one of the features I wanted the project to have was an
    automated suggestion service. If anyone has been to Amazon, it would work much like their
    recommended product feature. What I want to do is take several users lists of whatever but for this
    example, I'll use web links like from the browser history. I would want to suggest links to a
    user based on common links in many other users lists. User A: Amazon, Ebay, Excite, Google, Yahoo,
    MySpace, Walmart User B: Amazon, Ebay, Google, Yahoo, You Tube, MySpace, CVS User C: Amazo...
  4. Converting <enter> To \n In Textbox - (2)
    I'm making a script that emails data and in the message box, I need all to be converted to \n
    so when it is mailed, it will format properly into: This is a test When submitted, it would be
    turned into: This \n is \n a \n test So that it can easily be mailed. Or does PHP do this
    automatically? Thanks! F...



Looking for logging, items, entered, textbox






*SIMILAR VIDEOS*
Searching Video's for logging, items, entered, textbox
advertisement




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