manmanda has asked for the wisdom of the Perl Monks concerning the following question:
below is the hello_post.cgi to handle input given by web browser<FORM action="/cgi-bin/hello_post.cgi" method="POST"> First Name: <input type="text" name="first_name"> <br> Last Name: <input type="text" name="last_name"> <input type="submit" value="Submit"> </FORM>
Here you can see that my logic and html tag are in same cgi script. My question is that how can i display the out in separate html form. means i want to separate business logic in cgi script and presentation logic in .jsp or .html etc#!/usr/bin/perl local ($buffer, @pairs, $pair, $name, $value, %FORM); # Read in text $ENV{'REQUEST_METHOD'} =~ tr/a-z/A-Z/; if ($ENV{'REQUEST_METHOD'} eq "POST") { read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); }else { $buffer = $ENV{'QUERY_STRING'}; } # Split information into name/value pairs @pairs = split(/&/, $buffer); foreach $pair (@pairs) { ($name, $value) = split(/=/, $pair); $value =~ tr/+/ /; $value =~ s/%(..)/pack("C", hex($1))/eg; $FORM{$name} = $value; } $first_name = $FORM{first_name}; $last_name = $FORM{last_name}; print "Content-type:text/html\r\n\r\n"; print "<html>"; print "<head>"; print "<title>Hello - Second CGI Program</title>"; print "</head>"; print "<body>"; print "<h2>Hello $first_name $last_name - Second CGI Program</h2>"; print "</body>"; print "</html>"; 1;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How to display output in separate html form in cgi script
by Kenosis (Priest) on Jan 24, 2014 at 04:29 UTC | |
by manmanda (Initiate) on Jan 24, 2014 at 05:38 UTC | |
by NetWallah (Canon) on Jan 24, 2014 at 05:53 UTC | |
by Anonymous Monk on Jan 24, 2014 at 07:10 UTC | |
|
Re: How to display output in separate html form in cgi script
by Anonymous Monk on Jan 24, 2014 at 03:47 UTC |