view mackey/academy/add.rb @ 2849:a222fe462b1b

merge
author ARAKI Tsuyohito <c113007@e.koeki-u.ac.jp>
date Tue, 01 Dec 2015 19:07:02 +0900
parents 2ee6e6efc0dd
children
line wrap: on
line source

#!/usr/bin/env ruby
# coding: euc-jp
require 'rubygems'
require 'pg'
require 'cgi'
c = CGI.new(:accept_charset => "euc-jp")
print"Content-type: text/html; charset=euc-jp\n\n"

number = c["id"]
pswd = c["pass"]
namae = c["name"]
sx = c["sex"]
check = 0

begin
  conn = PGconn.connect('broy.e.koeki-u.ac.jp','','','','c112085','mackeyacademy','l3nl3q1u')
  a = "select id from userdata"
  ip = conn.exec(a)
  ip.each do |row|
    if number == row["id"]
      check = 1 
    end
  end
  if check == 0
    q = "insert into userdata (id, password, name, sex, level, exp, quest) values ('#{number}', '#{pswd}', '#{namae}', '#{sx}', '1', '0', '0')"
    export = conn.exec(q)
  end
end
print"<html>
<head>
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=euc-jp\">
<title>ユーザー登録</title>
<link rel=\"stylesheet\" href=\"style.css\" type=\"text/css\">
</head>
<body>\n"
if check == 0
  print"<h1>登録完了</h1>
<a href=\"login.html\">
<button class=\"css3button\">ログイン</button>\n"
elsif check == 1
  print"<h1>Error</h1>
<p>既にIDが使われています</p>
<a href=\"add.html\">
<button class=\"css3button\">もう一度</button>\n"
end
print"</a>
</body>
</html>\n"

yatex.org