Results 1 to 4 of 4
  1. #1

    a bit of php help

    I was wondering if someone could point me in the right direction here, Basically i want a web form that would write the contents to a file. Every time the form is submitted, that contents of the form would replace what was currently in the file.

    I'm assuming I'll be using fwrite but if someone could point me where to look for more info I'd appriciate it.

    Thanks, Pam

  2. #2
    Join Date
    Dec 2002
    Location
    chica go go
    Posts
    11,876
    you could try...

    PHP Code:
    <?PHP

    $data 
    $_POST["data"];

    system('rm -rf datafile'); system('touch datafile'); system('echo "$data" > datafile');

    ?>
    then, in the html code for the form you could do something like...

    Code:
    <textarea name="data"></textarea>

    Make sure to have permissions set on datafile set to 777.

  3. #3
    Join Date
    Apr 2003
    Location
    London, UK
    Posts
    4,721
    PHP Code:
    if($submit) {
       
    $fp fopen("file.txt""w");
       
    fputs($fp"$_POST['data']");
       
    fclose($fp);
       
       echo 
    "Form Submitted, thanks!";

    data being the input name from your form, if you have several do something like

    $data = "".$_POST['input1']."<br>".$_POST['input2']."";

    and

    fputs($fp, "$data");

    or whatever
    Last edited by Ash; 04-07-2004 at 07:55 PM.
    Hyperconfused (™)

  4. #4
    Loon's code is what I would use as well. Not sure about the other.
    Mark - Owner/Lead Designer
    avidInteractive
    Lead vocalist for Circle7: Circle7 on MTV

Posting Permissions

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