Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Simple question about CGI response after form data has beenprocessed.

Reply
Thread Tools

Simple question about CGI response after form data has beenprocessed.

 
 
Ted Byers
Guest
Posts: n/a
 
      10-09-2009
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
 
Reply With Quote
 
 
 
 
Steve C
Guest
Posts: n/a
 
      10-09-2009
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
 
Reply With Quote
 
 
 
 
Brian Wakem
Guest
Posts: n/a
 
      10-09-2009
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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
FAQ 9.1 What is the correct form of response from a CGI script? PerlFAQ Server Perl Misc 0 04-21-2011 10:00 AM
JavaScript for Form (using CGI formmail) that sends user a copy ofthe form data TPK Javascript 1 08-27-2010 12:49 PM
CGI (read multipart form): Accept-Charset encoding error (CGI::InvalidEncoding) Stefan Fischer Ruby 2 02-23-2010 08:17 AM
Response.Redirect after a Response.Flush danielhamd@yahoo.com ASP .Net 5 06-12-2007 05:10 PM
Response.Redirect after Response.Flush Glen Wilkin via DotNetMonster.com ASP .Net 2 04-15-2005 03:29 PM



Advertisments