1. Howdy! Welcome to our community of more than 100.000 members devoted to web hosting. This is a great place to get special offers from web hosts and post your own requests or ads. To start posting sign up here. Cheers! /Peo, FreeWebSpace.net

PHP Form that creates a File

Discussion in 'Webdesign / HTML' started by LSComputers, Apr 27, 2012.

  1. LSComputers

    LSComputers NLC NLC

    Messages:
    2,112
    Likes Received:
    49
    Trophy Points:
    0
    Hello Guys,

    Been a while, I've been trying to develop a PHP form that will on submit create two files in specific folders. I've never done this but based on what I have read this shouldn't be difficult. I'm hoping someone can point me in the right direction:

    PHP Form Options:

    New Customer: YES | NO
    ---> This will create a file user.txt

    Name: TEXT BOX
    Product: OPTION 1 | OPTION 2 | OPTION 3
    ----> These will create a file order.txt

    This would be created in one form ideally on one page however could be configured under two if required. I found:
    http://php.about.com/od/advancedphp/ss/file_write_php.htm

    But I'm not an expert in this field and need a jumping off point.
     
  2. wswd

    wswd NLC NLC

    Messages:
    1,451
    Likes Received:
    48
    Trophy Points:
    148
    This will create the file if it doesn't exist:

    <?php
    $File = "YourFile.txt";
    $Handle = fopen($File, 'w');
    ?>


    This will write data to it:

    <?php
    $File = "YourFile.txt";
    $Handle = fopen($File, 'w');
    $Data = "Jane Doe\n";
    fwrite($Handle, $Data);
    $Data = "Bilbo Jones\n";
    fwrite($Handle, $Data);
    print "Data Written";
    fclose($Handle);
    ?>
     

Share This Page