PDA

View Full Version : Script which saves txt to a file (or template)?



( - P z Y - )
March 21st, 2002, 00:02
..I know nothing helpful about any real scripting langauges (only VERY basics), so I ask. Anyone know of something which can save data submitted by a form to a flat file database or a template?
Thanks.

Dusty
March 21st, 2002, 13:34
Well, I don't know what kind of form you're talking about or what you want to do with the data, so you may need something a bit more complex than this:
#!perl

open(FILE,">>/path/to/data/file.txt");
foreach $pair(split(/&/,read(STDIN,$buffer,$ENV{'CONTENT_LENGTH'}))){
($name,$value)=split(/=/,$pair);
$value=~tr/+/ /;
$value=~s/%(..)/pack("c",hex($1))/ge;
print FILE $name.": ".$value."\n\n";
}
print FILE "---\n\n";
close(FILE);
print "Location: http://url/to/thankyou/page.html\n\n";

invalid
March 21st, 2002, 18:58
yeah, what language?

coldturkey
March 22nd, 2002, 04:35
Originally posted by Dusty


print "Location: http://url/to/thankyou/page.html\n\n";

uhh, why do you have the \n\n at the end?

Ajiang
March 22nd, 2002, 06:18
I can only do it with ASP/FSO.

Dusty
March 22nd, 2002, 11:59
uhh, why do you have the \n\n at the end?It signifies the end of the header. Or a more simple answer, it won't work without it.