sdslrn123 has asked for the wisdom of the Perl Monks concerning the following question:
My Program, guestbook.pl:<html><head> <title>Guestbook</title> </head> <body> <form action="/cgi-bin/guestbook.pl" method="get"> <table> <tr><td>Comments</td><td> <TEXTAREA name="comments" rows="10" cols="32"></TEXTAREA></td></tr> </table><br><br> <input type="submit" value="Add Entry"> </form> </body> </html>
#!/usr/local/bin/perl my $query_string = ""; #Get the input if ($ENV{REQUEST_METHOD} eq 'POST') { read(STDIN, $query_string, $ENV{CONTENT_LENGTH}); } else { $query_string = $ENV{QUERY_STRING}; } ##### We will remove this print "Content-Type: text/html\n\n"; print "Query String is \n<br> $query_string"; ##### We will remove this # Split the name-value pairs @pairs = split(/&/, $query_string); foreach $pair (@pairs) { ($name, $value) = split(/=/, $pair); #Converting Hex to English. $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $value =~ tr/+/ /; $FORM{$name} = $value; } @thanks = split (/ /, $FORM{'comments'}); foreach $thank (@thanks){ $FORM{$thank} = $thank; } #Give output print <<END; Content-Type: text/html\n\n <html><head> <title>Guest book Result</title> <body> <h1 align="center">Guest book Results</h1> <br> Comments : $FORM{'comments'} <br> Words: $FORM{$thank} </body> </html> END
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Taking Variable from Form Entry Using CGI
by shmem (Chancellor) on Jul 02, 2006 at 14:38 UTC | |
by sdslrn123 (Novice) on Jul 02, 2006 at 15:17 UTC | |
by shmem (Chancellor) on Jul 02, 2006 at 15:36 UTC | |
by davido (Cardinal) on Jul 02, 2006 at 16:29 UTC | |
|
Re: Taking Variable from Form Entry Using CGI
by Ovid (Cardinal) on Jul 02, 2006 at 21:34 UTC | |
by Joost (Canon) on Jul 02, 2006 at 22:10 UTC |