Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

HTML form to txt file

  • 18-12-2006 05:25PM
    #1
    Closed Accounts Posts: 78 ✭✭


    Hi,

    I am trying to write some pages for my department in work. While I can find my way around HTML - haven't really used asp, php etc.

    I want to write a form that posts to a text file or csv file. Is this possible? Could any one give me a sample of the code.

    I could do this in asp with an access database but i've just discovered the server can handle sql and php but not asp and so it won't work and I have to use this server. I just need something simple that works. I can't have it coming to my email so a text file would be ideal. Any help would be greatly appreciated.

    J


Comments

  • Registered Users, Registered Users 2 Posts: 684 ✭✭✭Gosh



    See here and here for examples of file handling

    Here's an example of opening a file to append data, assumes POSTed data
    exists and has been validated

    [php]
    <?php

    // Open the file in append mode - create it if it doesn't exist
    $fp = fopen("textfile_name.txt", "a");

    // Write form_field_1 plus newline to file

    fwrite($fp, $_POST . "\r\n");

    // Write form_field_2 plus newline to file

    fwrite($fp, $_POST . "\r\n");
    // Close the file
    fclose($fp);

    ?>
    [/php]



Advertisement