Jesse Smith has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl ################### use CGI ':standard'; use CGI qw(:standard); # then only CGI.pm defines a head() $page = param('page'); #/cgi-bin/edit.cgi?page=edit print header(); if ($page eq 'edit') { #This part creates a form with the content from the edit.shtml file. use LWP::Simple; $content = get ('http://www.domain.com/edit.shtml'); print <<EOM; <title>Test</title> <meta http-equiv="Cache-Control" content="no-cache, no-store, must-rev +alidate"> <META HTTP-EQUIV="Expires" CONTENT="-1"> <HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE"> <FORM METHOD=POST ACTION="http://www.domain.com/cgi-bin/edit.cgi" name +="myForm"> <textarea title="Content (optional)" name="content2" cols="100" rows=" +50">$content</textarea> <BR><input type="submit" value="SUBMIT"/></form> EOM } else { $database = "/home/site139/public_html/edit.shtml"; # Get the input read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); # Split the name-value pairs @pairs = split(/&/, $buffer); foreach $pair (@pairs) { ($name, $value) = split(/=/, $pair); $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $FORM{$name} = $value; } { #Here I delete the edit.shtml page. open my $empty_the_file, "> /home/site139/public_html/edit.shtml" or d +ie "Can not write file: edit.shtml $!" ; close $empty_the_file; #Here I try to put in the data from the form but $FORM{'content2'} doe +sn't get registered. open (DATABASE,">>$database"); print DATABASE "$FORM{'content2'}\n"; close(DATABASE); } print <<EOM; <HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE"> Page edited. <P> $FORM{'content2'} EOM exit; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Use a perl script to empty a file and then replace it with data from a web form
by haukex (Archbishop) on Dec 05, 2017 at 06:31 UTC | |
|
Re: Use a perl script to empty a file and then replace it with data from a web form
by 1nickt (Canon) on Dec 05, 2017 at 03:33 UTC | |
|
Re: Use a perl script to empty a file and then replace it with data from a web form
by Anonymous Monk on Dec 05, 2017 at 03:40 UTC |