[#34722] cgi.rb の form の挙動 — FUJIOKA Takeyuki <fujioka@...>

藤岡です。

18 messages 2002/04/02

[#34724] 「たのしい Ruby 」 — Shin-ichiro HARA <sinara@...>

原(信)です。

18 messages 2002/04/02
[#34728] Re: 「たのしい Ruby 」 — matz@... (Yukihiro Matsumoto) 2002/04/02

まつもと ゆきひろです

[#34746] Re: 「たのしい Ruby 」 — TAKAHASHI Masayoshi <maki@...> 2002/04/02

高橋征義です。

[#34752] Re: 「たのしい Ruby 」 — Shin-ichiro HARA <sinara@...> 2002/04/03

原(信)です。

[#34842] [ann] Web 家計簿(β版)リリース — 堀川 久 <vzw00011@...>

こんにちは。

18 messages 2002/04/07
[#34869] Re: [ann] Web 家計簿(β版)リリース — Nobuhide Kanagawa <nobuhide@...> 2002/04/11

こんばんわ!

[#34885] creating a scope / anonymous module — Takaaki Tateishi <ttate@...>

立石です.

38 messages 2002/04/13
[#34891] Re: creating a scope / anonymous module — nobu.nakada@... 2002/04/14

なかだです。

[#34892] Re: creating a scope / anonymous module — Takaaki Tateishi <ttate@...> 2002/04/14

At Sun, 14 Apr 2002 18:00:12 +0900,

[#34894] Re: creating a scope / anonymous module — nobu.nakada@... 2002/04/14

なかだです。

[#34896] Re: creating a scope / anonymous module — Takaaki Tateishi <ttate@...> 2002/04/14

At Sun, 14 Apr 2002 21:08:47 +0900,

[#34899] Re: creating a scope / anonymous module — matz@... (Yukihiro Matsumoto) 2002/04/15

まつもと ゆきひろです

[#34901] Re: creating a scope / anonymous module — Takaaki Tateishi <ttate@...> 2002/04/15

At Mon, 15 Apr 2002 09:51:05 +0900,

[#34902] Re: creating a scope / anonymous module — matz@... (Yukihiro Matsumoto) 2002/04/15

まつもと ゆきひろです

[#34903] Re: creating a scope / anonymous module — Takaaki Tateishi <ttate@...> 2002/04/15

At Mon, 15 Apr 2002 13:53:53 +0900,

[#34904] Re: creating a scope / anonymous module — matz@... (Yukihiro Matsumoto) 2002/04/15

まつもと ゆきひろです

[#34910] Re: creating a scope / anonymous module — Takaaki Tateishi <ttate@...> 2002/04/15

At Mon, 15 Apr 2002 15:07:57 +0900,

[#34958] windows 版 ruby でシステムコマンドが動かない — "jazzski _comp" <jazzski_comp@...>

はじめてrubyを使うのですが、windows版(cygwin版1.6.1)で下記のように

12 messages 2002/04/23

[ruby-list:34754] 続: cgi.rb の form の挙動

From: FUJIOKA Takeyuki <fujioka@...>
Date: 2002-04-03 08:49:29 UTC
List: ruby-list #34754
藤岡です。 
 
まだダメなようです。sessionの方の対応をしてみたのですが, 
投稿フォームから投稿フォームへセッションを持ったままいくとエラーです。 
具体的なプログラムは以下です。 
コメントアウトの部分と入れ替えるとうまくいきます。 
 
#!/usr/bin/ruby
require "kconv"
require "cgi"
require "cgi/session"

class SessionDemo
  def initialize
    @cgi = CGI::new("html3")
    File.umask(0066) # セッションファイルは誰にも読まれたくないよ
    @session = CGI::Session::new( @cgi) # セッションはこうして生成する。
    @cmd=""
    if @cgi['cmd'].first!=nil
      if @cgi['cmd'].first.type==String
	@cmd = @cgi['cmd'].first
      else
	@cmd = @cgi['cmd'].first.read
      end
   else
      @cmd='start'
    end
    @header = { "type" => "text/html", "charset" => "euc-jp" }
    __send__("cmd_#{@cmd}")
  end

  def cmd_start
    @cgi.out(@header){
      @cgi.html{
	@cgi.head{@cgi.title{"CGI::Session Demo"}}+
	  @cgi.body{
	  @cgi.form("METHOD"=>"post","ENCTYPE"=>"multipart/form-data",
		    "action"=>"#{ENV['SCRIPT_NAME']}"){
	    <<-END
<p>
あなたの名前は?
<input type="text" name="name" value="fujioka">
<input type="hidden" name="cmd" value="hello">
<input type="submit" value="です。">
</p>
END
        }
      }
    }
}
  end
  def cmd_hello
    @session['name'] = Kconv::toeuc( @cgi['name'].first.read )
    name  = @session['name'] # セッションに記憶
    @cgi.out( @header ) {
      # セッション情報は隠れクッキーで保持されるため、CGI#outで出力
      @cgi.html{
	@cgi.head{@cgi.title{"CGI::Session Demo"}}+
	  @cgi.body{
	  @cgi.p{"こんにちは、#{name}さん"}+
#      <<-END
#<form method="post" action="#{ENV['SCRIPT_NAME']}">
#<input type="hidden" name="cmd" value="bye">
#<input type="submit" value="次へ">
#</form>
#END
	    @cgi.form("method"=>"post","action"=>"#{ENV['SCRIPT_NAME']}"){
	    @cgi.input("type"=>"hidden","name"=>"cmd","value"=>"bye")
	    @cgi.input("type"=>"submit","value"=>"次へ")
	  }
	}
      }
    }   
  end
  def cmd_bye
    name = @session['name'] # セッションデータから取り出し
    @cgi.out( @header ) {
      <<-END
      <html><head><title>CGI::Session Demo</title></head>
<body>
<p>#{name}さん、さようなら</p>
<p><a href="#{ENV['SCRIPT_NAME']}">[戻る]</p>
</body>
END
    }
  end
end

SessionDemo.new

In This Thread