From: Ted Byers on
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
From: Steve C on
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
From: Brian Wakem on
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
 | 
Pages: 1
Prev: CGI and UTF-8
Next: permutations of symbols?