CGI and re-direction

I have written a simple CGI script. It loads in an object, and prints
out a few of its attributes. I would like to add some check-boxes such
that when I hit the submit button some other booleans get set, it
accesses a second CGI page, which updates the object based on the
cgi.params, and then returns to the first page so that the object can be
be re-displayed (hope that all makes sense - it’s getting late!)

So my question is, how do I redirect back to the first page from the
second? Or is there another (better) way to achieve the same result
(perhaps by using just the one page)

Thanks!

So my question is, how do I redirect back to the first page
from the second? Or is there another (better) way to achieve
the same result (perhaps by using just the one page)

Just post to the same script, and have it check whether it has been
posted to, and, optionally, an action parameter (in case a previous page
posts to it) to tell it which action needs to be taken.

-Doug

Doug P. wrote:

So my question is, how do I redirect back to the first page
from the second? Or is there another (better) way to achieve
the same result (perhaps by using just the one page)

Just post to the same script, and have it check whether it has been
posted to, and, optionally, an action parameter (in case a previous page
posts to it) to tell it which action needs to be taken.

-Doug

Thanks for the quick reply. If I use the same script don’t I have
problems using cgi.params, as on the first visit they don’t exist? Or
do I use an if…then to choose between two pages (one used pre-posting
and the other post-posting(!)) As you can tell, I’m not a programmer per
se, so any examples (or pointers to examples) would be very much
appreciated.

thanks again

[Clarification of previous post]
when I said “do I use an if…then to choose between two pages (one
used pre-posting and the other post-posting” what I meant was:

#!/bin/ruby

if FIRST_VISIT # (how do I test?)
cgi.out { a page not referring to cgi.params}
else
cgi.out { a page using cgi.params }
end

Or can I avoid this? Thanks!

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs