Results 1 to 4 of 4

Thread: removing from file

Threaded View

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Sep 2005
    Posts
    1,364

    removing from file

    The code below adds text to the file in the format of:

    www.my-site.com/filename.php?data=hello

    PHP Code:
    <?php
    $filename 
    'test.txt';
    $somecontent $_GET['data'] . "\n"

    if (
    is_writable($filename)) {

       if (!
    $handle fopen($filename'a')) {
             echo 
    "Cannot open file ($filename)";
             exit;
       }

       if (
    fwrite($handle$somecontent) === FALSE) {
           echo 
    "Cannot write to file ($filename)";
           exit;
       }
       
       echo 
    "Success, wrote ($somecontent) to file ($filename)";
       
       
    fclose($handle);

    } else {
       echo 
    "The file $filename is not writable";
    }
    ?>
    but then how can i make a php file which will allow me to remove the word 'hello' from test.txt

    www.my-site.com/remove.php?data=hello
    any help on this please?
    Last edited by Pouncer; Sep 22nd, 2005 at 06:40 PM.

Posting Permissions

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



Click Here to Expand Forum to Full Width