#!/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")
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")