Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: How to display output in separate html form in cgi script

by Kenosis (Priest)
on Jan 24, 2014 at 04:29 UTC ( [id://1071874]=note: print w/replies, xml ) Need Help??


in reply to How to display output in separate html form in cgi script

If you're going the Perl CGI route, consider using the CGI module (sorry, chromatic).

If I understand your question correctly, you want a separate CGI script and a resulting html document. That is, instead of a dynamically-created html document, you'd like a static html document created by the script.

This can certainly be done, by writing the results to an html file, and then redirecting the browser to that file. You'd need write permissions for both the dir and file you're writing to. But now it gets a little messy...

You'd need to create a unique filename for each response--for each new htnl document that the CGI script creates. Additionally, you'd need to figure a way to deal with all the html files that your CGI script is creating. Do you leave them in the directory? If you're going to delete them, how long after they're created and how often?

You need to answer for yourself whether creating static html files from a CGI script is better than creating the pages 'on the fly,' as your script above does.

  • Comment on Re: How to display output in separate html form in cgi script

Replies are listed 'Best First'.
Re^2: How to display output in separate html form in cgi script
by manmanda (Initiate) on Jan 24, 2014 at 05:38 UTC
    I mean to say that i want to redirect the result to another cgi script suppose result.cgi which will display the output
    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>";
    but how result.cgi will fetch the $first_name $last_name from hello_post.cgi?
      The same way your script does - using $ENV{'QUERY_STRING'};

      As suggested earlier, the CGI module (use CGI;) makes programming this a lot easier, by offering you param("first_name") etc.

              If your eyes hurt after you drink coffee, you have to take the spoon out of the cup.
                    -Norm Crosby

      I mean to say that i want to redirect the result to another cgi script suppose result.cgi which will display the output

      Um, what do you mean by redirect? HTTP redirect (aka location header)?

      Or do you simply want to change the form action to  <FORM action="something.else/the_script_i_really_wanted.cgi"  > ??

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1071874]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (6)
As of 2024-04-23 16:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found