• Howdy! Welcome to our community of more than 130.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

LSComputers

Well-Known Member
NLC
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.
 

wswd

Premium
Premium Member
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);
?>
 
Top