From: Niklas Backlund Date: 2001-11-16T07:14:22+09:00 Subject: [ruby-talk:25343] CGI beginner's trouble Hi, I'm failing with CGI on such a basic level, it's almost scary! So please, if you're sensitive, stop reading now... =) I've been working on a new web page using mod_ruby and eRuby for Apache. The eRuby stuff I've done has been working perfectly, so no complaints there! The thing is that I want to be able to submit data to my webpage when I'm travelling, and I thought the easiest way to accomplish this would be to have a "backdoor page" with a CGI form where I could enter the text I want to submit. Later, I would include functions to preview my entry before submitting and editing previous entries. However, the problems start already during the first step... Being the novice I am, I used the examples in "Programming Ruby" as a starting point. Here's my first primitive program: require 'cgi' cgi = CGI.new("html3") cgi.out { cgi.html { cgi.head{ cgi.title{"Submit news..."} } + cgi.body{ "\n" + cgi.form{ "\n" + cgi.textarea("get_text") + "\n" + cgi.br + cgi.submit("Submit") } } } } if cgi["get_text"] != nil print "Previous result: " + cgi["get_text"].to_s end It works as I expected to: I enter some text, hit 'Submit' and I get the same page again, this time with the result printed below the form (just for testing). But I want to save the text I entered to a text file (or whatever) and send back some confirmation text -- I don't want the form to appear again. If I try to acheive this with some test ( if cgi["get_text"] == nil cgi.out{...} ) I will get stuck in the "presentation mode", because when trying to reload the page, I have to repost the form data, which will prevent me from getting the form back again... How do I make it "forget" my previous entry? Or did I get it all wrong somehow...? I was unable to try things out in 'irb' (as I usually do when I'm experimenting) as I also get the following dilemma: irb(main):001:0> require 'cgi' true irb(main):002:0> cgi = CGI.new("html3") (offline mode: enter name=value pairs on standard input) from which there seems to be no escape other than breaking out of 'irb'... /Niklas