Results 1 to 2 of 2

Thread: string enter to text file in PHP

  1. #1

    Smile string enter to text file in PHP

    Dear All,
    I need to write a script in php that used to enter word list to text file through html page. After user enter the word to the text file, it should check for NULL char, empty line and already entered word(to avoid duplicate input). I have written that but I can enter the words it doesent check for duplication. Pls be kind enough help me to fix this script.

    <title>Form Examples by Kaela Street</title>
    <h2 align="center"><b>Spam Reporting System</b></h2>
    <form name="form" action="<?php echo $_SERVER["PHP_SELF"]; ?>" method="post">
    Add to list<input type="text" name="Input" /><input type="submit" />
    function add_string($filename,$AddAddr)  //Add function
        if ($HanDle == FALSE)   //File open check
            $AnsWer="File open error";
            return $AnsWer;      
            for($line=0; $line>$Array_size; $line++)  //Address already their check
                $WoRd = "/\b".$AddAddr."\b/";
                if ( preg_match($WoRd,$Data_array[$line]) )
                //if (strcmp($Data_array[$line],$AddAddr) == 0)
                    echo "found in line ".$line;
                    //$AnsWer="Address already there ".$line;
                    return $AnsWer;
        if (fprintf($HanDle,"%s\n",$AddAddr) == FALSE)   //write address to end of file
            $AnsWer = "write failed";
            return $AnsWer;  
            $AnsWer="Record added";
        return $AnsWer;  
    if($Word1 != NULL || $Word != '')
        echo add_string('file123',$Word);

  2. #2

    $line = file($filename);
    foreach ($line as $line_num => $line) 
        if ($line == $WoRd)
            echo "line exists";
            echo "line does not exist";
    Sorry for the short answer, but hope it helps.
    arrogance breeds ignorance

    Screaming Electron, Full of BSD Goodness

Similar Threads

  1. Text file syntax highlighting/Export to HTML
    By vwgtiturbo in forum Linux - Software, Applications & Programming
    Replies: 1
    Last Post: 06-23-2006, 05:36 AM
  2. export to a text file with comma & quote delimiter
    By regix in forum Windows - General Topics
    Replies: 0
    Last Post: 01-04-2005, 01:33 AM
  3. text file search tool
    By phpewb in forum Linux - General Topics
    Replies: 3
    Last Post: 12-04-2004, 03:48 PM
  4. Got the text driver file - now, how to use it?
    By Phaete in forum Linux - General Topics
    Replies: 6
    Last Post: 05-07-2002, 01:16 PM
  5. String of text into file?
    By MZGuy in forum Linux - General Topics
    Replies: 8
    Last Post: 01-03-2002, 09:18 AM


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts