/    Sign up×
Community /Pin to ProfileBookmark

writing form information to a note pad

hi is there anything which could take data imput from an HTML form and put it into a *.txt file.

I have no idea how to write php, I’d like to learn, but I don’t think I’ll have time before I have to put the page up.

…So it’s going to have to be something I can chop copy and paste. Sorry all, and thanks for any help in advance.

to post a comment
PHP

5 Comments(s)

Copy linkTweet thisAlerts:
@MstrBobNov 07.2004 — Here's a bare-bones form handler that I just whipped up. All you need to do is create an empty file called form_results.txt, and then Put this code into a new .php file. Point your form's action="" to the php file, and you're ready to role.

[code=php]
<?PHP
if(!empty($_POST))
{
$results='--------------------------'."n".'Form received on '.date('F j, Y')."nn";
$array=$_POST;
foreach($array as $key => $value)
{
$results.=$key.': '.htmlentities(stripslashes($value))."nn";
}
$handle=fopen('form_results.txt', 'a');
if (fwrite($handle, $results) === false)
{
echo "Error writing to file ($filename)";
die();
}
fclose($handle);
echo("You're form results have been successfully submitted.");
} else {
header('Location: '.$_SERVER['HTTP_REFERER']);
}
?>
[/code]
Copy linkTweet thisAlerts:
@bolauthorNov 08.2004 — Thanks very much, I'll give it a go - but don't be surprised if I make some glaringly stupid mistake and come running back with more questions. ?
Copy linkTweet thisAlerts:
@bolauthorNov 08.2004 — Just as I expected....

what roughly would the html look like - are there any other things I need to do to point to the php file aside from setting the action attribute?
Copy linkTweet thisAlerts:
@MstrBobNov 08.2004 — I set it up to be very general. Just make your form properly. Like each field should have an unique name, which is necessary for all forms to work properly. But nothing special need be done.
Copy linkTweet thisAlerts:
@bolauthorNov 08.2004 — giving it another go now
×

Success!

Help @bol 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 4.28,
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: @Yussuf4331,
tipped: article
amount: 1000 SATS,

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

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...