
Xentic
stranger
Nov 7, 2001, 12:27 AM
Post #6 of 6
(513 views)
|
|
Re: Writing form data to txt file...
[In reply to]
|
Can't Post
|
|
HI! This is the script. Who knows i can add the script Dennis told me to use? Any help would be apreciated a lot! #!/usr/bin/perl $pass = "My Password"; $allow_html = 1; # 1 = Yes; 0 = No $datafile = "../newsite/html/nieuws.txt"; $scriptlocation = "../cgi-bin/add2file.pl"; read(STDIN, $input, $ENV{'CONTENT_LENGTH'}); @pairs = split(/&/, $input); foreach $pair (@pairs) { ($name, $value) = split(/=/, $pair); $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $value =~ s///g; if ($allow_html != 1) { $value =~ s/<([^>]|\n)*>//g; } $FORM{$name} = $value; } $password = $FORM{'password'}; $zach = $FORM{'zach'}; $addthistofile = $FORM{'addthistofile'}; unless ($password eq "$pass") { print "Content-type: text/html\n\n"; print "<HTML><HEAD><TITLE>Add2File</TITLE></HEAD>\n"; print "<BODY BGCOLOR=BLACK TEXT=WHITE><CENTER><H1>Add2File</H1><BR>\n"; print "<FORM ACTION=\"$scriptlocation\" METHOD=\"POST\">\n"; print "Please submit the admin password to use Add2File\.\n"; print "<BR><INPUT TYPE=TEXT SIZE=10 NAME=\"password\">\n"; print "<INPUT TYPE=SUBMIT VALUE=\"Submit your Password\">\n"; print "</FORM></CENTER></BODY></HTML>\n"; exit; } ####################################################################### ####Generate the configuration form page############################### ####################################################################### unless ($zach eq "makechanges") { print "Content-type: text/html\n\n"; print "<HTML><HEAD><TITLE>Add2File</TITLE></HEAD>\n"; print "<BODY BGCOLOR=BLACK TEXT=WHITE><CENTER><H1>Add2File</H1><BR>\n"; print "<FORM ACTION=\"$scriptlocation\" METHOD=\"POST\">\n"; print "In the text box below, enter what you need to add to your file\.\n"; print "<BR><textarea SIZE=40 NAME=\"addthistofile\"> <b>dd-mm-jaar</b> </textarea>\n"; print "<INPUT TYPE=HIDDEN NAME=\"password\" VALUE=\"$pass\">\n"; print "<INPUT TYPE=HIDDEN NAME=\"zach\" VALUE=\"makechanges\">\n"; print "<INPUT TYPE=SUBMIT VALUE=\"Add2File\">\n"; print "</FORM></CENTER></BODY></HTML>\n"; exit; } ####################################################################### #### Write text to file ############################################### ####################################################################### #open your file for writing, write to it then close file die ("Cannot open your datafile\n") unless open (FILE, ">>$datafile"); print FILE "$addthistofile\n"; close(FILE); ####################################################################### #### Print Finish message ############################################# ####################################################################### print "Content-type: text/html\n\n"; print "<HTML><HEAD><TITLE>Add2File</TITLE></HEAD>\n"; print "<BODY BGCOLOR=Black TEXT=WHITE><CENTER><H1>Add2File</H1><BR>\n"; print "Ok\, your file has been updated\.\n"; print "Thanks for using Add2File\n"; print "</BODY></HTML>\n"; exit;
|