Page 1 of 1

PHP Saving to a File

Posted: Tue May 22, 2007 10:39 pm
by reyes99
Hi Everyone,

I am new to PHP..

I created a form that I would like to save to a file like a .txt files or .csv file.

Is this possible with PHP?? If so how?? I tried searching google but did not find anything.

Thanks

Ralph

Posted: Tue May 22, 2007 10:54 pm
by bdlang
Yes, take a look in the manual at some of the file functions. Start with fopen().

If you want to avoid the headache of storing data in flatfiles, you might consider working with SQLite or MySQL. Depending on your specific application, of course.

Posted: Wed May 23, 2007 12:06 am
by PHPycho
Perform this:

Code: Select all

$file .= "";
$file .= "<?php";
$file .= "//php contents goes here.. ";
$file .= "?>";

$fs = @fopen("$savepath/" . $filename . '.php', 'w+t');
@fwrite($fs, $file);
@fclose($fs);
Hope this may help You

Posted: Wed May 23, 2007 9:40 am
by reyes99
Thank you guys...

I will try that

Ralph