Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

HTML form to txt file

  • 18-12-2006 4: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: 683 ✭✭✭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