#!/usr/bin/env ruby $KCODE = 'e' require 'cgi' require 'pstore' cgi = CGI.new("html4") db = PStore.new("lunch.db") myprog = "lunch_cmt.rb" print("Content-type: text/html; charset=EUC-JP\n\n") studentid = cgi["studentid"] studentname = cgi["studentname"] comment = cgi["comment"] if (studentname == "" || studentid == "" || comment == "") print("必要事項が入力されていません") # exit(1) # end print("\n") print("\n") print("\n") print("定番メニューよありがとう\n") print("\n") print("\n") print("

送信フォーム

\n") printf("
\n",myprog) print("

学籍番号 :

\n") print("名前 :

\n") print("その理由 :

\n") print("

\n") print("
\n") print("

感謝の気持ち

\n") print("
\n")
  
db.transaction do

  if db["opinion"] == nil
    db["opinion"] = Hash.new      # PStore 配列の key "opinion" にしまうデータは
                                  # Hash 形式で
  end
  opinion = db["opinion"]         # 今までの PStore 配列全てを opinion 
                                  # にしまっておく
  opinion[studentname] = comment  # studentname を key, comment を value で
                                  # しまう

  opinion.keys.each{|someone|     # 今登録したのも含めて全て表示
    if opinion.key? == true
      printf("%sさん: ",someone)
      printf("%s\n", opinion[someone])
    end
  }
end  

print("
\n") print("\n") print("\n")