/    Sign up×
Community /Pin to ProfileBookmark

is there any php code (or other code for that matter) that captures the information entered in textfields and outputs it as a readable textfile or legible file and places it a designated folder on the webserver?

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@NogDogJun 14.2005 — [code=php]
$folder = "/home/username/formdata";
$file = "$folder/form_input_" . time() . ".txt"; # use time for unique file name
$delimiter = "t"; # field delimiter for text file, in this example a tab character
if($handle = fopen($file, 'w'))
{
foreach($_POST as $key => $val)
{
fwrite($handle, "$key$delimiter$val");
}
fclose($handle);
}
else
{
echo "<p>ERROR: Unable to open file $file for writing.</p>n";
}
[/code]
Copy linkTweet thisAlerts:
@xredawg909xauthorJun 15.2005 — a question.. this is for a form submit online, when multiple people submit their forms, will the code automatically label them differently? (i.e. Fquote.txt, Fquote2.txt, etc.., etc..) or will it overwrite each time someone submits a form?
Copy linkTweet thisAlerts:
@NogDogJun 15.2005 — The example I gave will include a timestamp value with each file name, so each file will be unique (unless two requests get processed within the same second). You could make it more unique if there is a user ID or some other unique value you could add to the file name.
×

Success!

Help @xredawg909x spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...