view staff/mackey/academy/add.rb @ 3944:e45173af0101 default tip master

chenge game link
author KOMATSU Kotaro <c118089@roy.e.koeki-u.ac.jp>
date Mon, 20 Jan 2020 18:13:48 +0900
parents b56bf1659fd5
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