Simple question about CGI response after form data has beenprocessed.

Discussion in 'Perl Misc' started by Ted Byers, Oct 9, 2009.

  1. Ted Byers

    Ted Byers Guest

    I have searched through my books, the FAQs I could find, the CGI
    documentation, and have not found the answer, probably just an
    oversight in the documentation I have examined.

    For the most part, I have found it extremely easy to use the CGI
    packages.

    My frustration is that, while it is trivially easy to get form
    parameters in my CGI scripts, I have not found how to either forward
    or redirect the user to the HTML form he had just used to submit the
    data my script had just processed. The script is just to move the
    data into a DB, send an error page if there is a problem, and
    otherwise return the user to the form ready to enter more data. The
    form itself is static, and so exists as a simple HTML file in htdocs
    (I'm using Apache's httpd).

    I found something about just printing "Location: some_uri", but unless
    the sources I read are mistaken, that needs a full path, and, as the
    code will be moved from my development machine to a final home, I can
    only know the relative path.

    I know I could have the contents of the HTML file in the cgi file too,
    but that carries its own problems WRT maintenance, and having the
    script read the file and then print it carries performance issues.

    What is the best option here?

    Thanks

    Ted
     
    Ted Byers, Oct 9, 2009
    #1
    1. Advertising

  2. Ted Byers

    Steve C Guest

    Ted Byers wrote:
    > I have searched through my books, the FAQs I could find, the CGI
    > documentation, and have not found the answer, probably just an
    > oversight in the documentation I have examined.
    >
    > For the most part, I have found it extremely easy to use the CGI
    > packages.
    >
    > My frustration is that, while it is trivially easy to get form
    > parameters in my CGI scripts, I have not found how to either forward
    > or redirect the user to the HTML form he had just used to submit the
    > data my script had just processed. The script is just to move the
    > data into a DB, send an error page if there is a problem, and
    > otherwise return the user to the form ready to enter more data. The
    > form itself is static, and so exists as a simple HTML file in htdocs
    > (I'm using Apache's httpd).
    >
    > I found something about just printing "Location: some_uri", but unless
    > the sources I read are mistaken, that needs a full path, and, as the
    > code will be moved from my development machine to a final home, I can
    > only know the relative path.
    >
    > I know I could have the contents of the HTML file in the cgi file too,
    > but that carries its own problems WRT maintenance, and having the
    > script read the file and then print it carries performance issues.
    >
    > What is the best option here?
    >
    > Thanks
    >
    > Ted



    The page that invoked your script is the referer. However, you can't
    trust any information in a request, so you need to consider
    the case where the caller lies to you. If you are just sending back
    a redirect to that page, then you probably don't care.

    If you generate a document with just a redirect header, then it suggests
    to the browser that it go fetch that page, which it will do if it
    feels cooperative.

    Both are described in
    perldoc CGI
     
    Steve C, Oct 9, 2009
    #2
    1. Advertising

  3. Ted Byers

    Brian Wakem Guest

    Re: Simple question about CGI response after form data has been processed.

    Ted Byers wrote:

    > I have searched through my books, the FAQs I could find, the CGI
    > documentation, and have not found the answer, probably just an
    > oversight in the documentation I have examined.
    >
    > For the most part, I have found it extremely easy to use the CGI
    > packages.
    >
    > My frustration is that, while it is trivially easy to get form
    > parameters in my CGI scripts, I have not found how to either forward
    > or redirect the user to the HTML form he had just used to submit the
    > data my script had just processed. The script is just to move the
    > data into a DB, send an error page if there is a problem, and
    > otherwise return the user to the form ready to enter more data. The
    > form itself is static, and so exists as a simple HTML file in htdocs
    > (I'm using Apache's httpd).
    >
    > I found something about just printing "Location: some_uri", but unless
    > the sources I read are mistaken, that needs a full path, and, as the
    > code will be moved from my development machine to a final home, I can
    > only know the relative path.
    >
    > I know I could have the contents of the HTML file in the cgi file too,
    > but that carries its own problems WRT maintenance, and having the
    > script read the file and then print it carries performance issues.
    >
    > What is the best option here?
    >
    > Thanks
    >
    > Ted



    use CGI;
    my $query = new CGI;

    print $query->redirect( -location => '/myform.html' );



    --
    Brian Wakem
     
    Brian Wakem, Oct 9, 2009
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Glen Wilkin via DotNetMonster.com

    Response.Redirect after Response.Flush

    Glen Wilkin via DotNetMonster.com, Apr 15, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    7,026
  2. Replies:
    9
    Views:
    30,377
    sameer.rede
    Sep 4, 2007
  3. Replies:
    0
    Views:
    4,292
  4. Replies:
    5
    Views:
    587
    =?ISO-8859-1?Q?G=F6ran_Andersson?=
    Jun 12, 2007
  5. TPK
    Replies:
    1
    Views:
    332
    Tim Slattery
    Aug 27, 2010
Loading...

Share This Page