CGI and re-direction

Discussion in 'Ruby' started by Toby Rodwell, May 16, 2007.

  1. Toby Rodwell

    Toby Rodwell Guest

    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!

    --
    Posted via http://www.ruby-forum.com/.
     
    Toby Rodwell, May 16, 2007
    #1
    1. Advertising

  2. Toby Rodwell

    Toby Rodwell Guest

    Doug Phillips 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

    --
    Posted via http://www.ruby-forum.com/.
     
    Toby Rodwell, May 17, 2007
    #2
    1. Advertising

  3. Toby Rodwell

    Toby Rodwell Guest

    [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!


    --
    Posted via http://www.ruby-forum.com/.
     
    Toby Rodwell, May 17, 2007
    #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. Efy.
    Replies:
    2
    Views:
    1,114
  2. Alexander Eisenhuth

    win32 COM and data types / direction

    Alexander Eisenhuth, Mar 4, 2005, in forum: Python
    Replies:
    2
    Views:
    334
    Tim Roberts
    Mar 6, 2005
  3. Nicolas Matringe

    Unconstrained array and range direction

    Nicolas Matringe, Oct 2, 2006, in forum: VHDL
    Replies:
    12
    Views:
    1,216
  4. sloan
    Replies:
    0
    Views:
    326
    sloan
    Feb 6, 2007
  5. NickName
    Replies:
    2
    Views:
    348
    NickName
    Nov 7, 2006
Loading...

Share This Page