Click to See Complete Forum and Search --> : Admin that writes to a text file
Punkit
07-10-2001, 03:45 PM
I'm looking for a CGI script that creates an Admin section where you can basically write a blurb and click submit and have it write over a .txt file. Simple right? why can't I find one?
Thanks!
------------------
"That's Right, I Said It,"
namgor
07-10-2001, 04:55 PM
I just wrote one for you, am i nice?
#!/usr/bin/perl
print "Content-type: text/html\n\n";
$filename = "player.txt";
# Get the input
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $buffer); # Split the name-value pairs
open (FILE, ">>$filename");
foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);
# Un-Webify plus signs and %-encoding
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$value =~ s/<!--(.|\n)*-->//g;
$value =~ s/<([^>]|\n)*>//g;
if ($value eq "Submit") { last; } else {
print FILE "$value#";
}
}
print FILE "\n";
close (FILE);
Basically, it parse thru the whole form and write all the fields in the file, seperated by a # sign.
------------------
DHAHL3seasons GP:73 G:121 A:55 Pts:176 GWG:12 +/-:184
UWSWA1season GP:9 G:12 A:8 Pts:20 GWG:3 +/-:-3
uwcdc.com (http://www.uwcdc.com) or namgor.com (http://www.namgor.com)
Punkit
07-10-2001, 05:39 PM
Very nice, where do I send the shareware fee to? http://www.sharkyforums.com/ubb/smile.gif
------------------
"That's Right, I Said It,"
Punkit
07-10-2001, 06:01 PM
OK Sorry, I'm not trying to be difficult, How can I clear the .txt file from the same form page as the one that submits the text?
------------------
"That's Right, I Said It,"
namgor
07-11-2001, 04:27 PM
You want to clear the text file? Then upload a blank file http://www.sharkyforums.com/ubb/smile.gif
Otherwise you need more codes... so are you sending me the shareware fees? http://www.sharkyforums.com/ubb/smile.gif (j/k)
------------------
DHAHL3seasons GP:73 G:121 A:55 Pts:176 GWG:12 +/-:184
UWSWA1season GP:9 G:12 A:8 Pts:20 GWG:3 +/-:-3
uwcdc.com (http://www.uwcdc.com) or namgor.com (http://www.namgor.com)