changeset 2525:9b51b5890f39

Exception handing
author ARAKI Tsuyohito <c113007@e.koeki-u.ac.jp>
date Tue, 14 Jul 2015 21:48:57 +0900
parents a4513a4b0d0c
children 92743fa59278
files oasis2015/prof.rb
diffstat 1 files changed, 47 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/oasis2015/prof.rb	Tue Jul 14 20:12:05 2015 +0900
+++ b/oasis2015/prof.rb	Tue Jul 14 21:48:57 2015 +0900
@@ -23,7 +23,9 @@
 
 bomd = "update test set pt = ? where id = ?"
 ins4 = 'insert into time values(?, 61, "n")'
+printf("Content-type: text/html; charset=UTF-8\n\n")
 
+begin
 name = cook[0][1]
 cal = cook[0][2]
 age = cook[0][3]
@@ -32,6 +34,40 @@
 exp = cook[0][6]
 pt = cook[0][7]
 lv = cook[0][8]
+rescue
+printf(<<_EOS_)
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
+	"http://www.w3.org/TR/html4/strict.dtd">
+<html><head>
+<meta name="viewport"
+content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no">
+<meta name="format-detection" content="telephone=no">
+<link media="only screen and (max-device-width:480px)"
+href="smart.css" type="text/css" rel="stylesheet" />
+<link media="screen and (min-device-width:481px)" href="profeel.css"
+type="text/css" rel="stylesheet" />
+<link rel="shortcut icon" href="./img/cabage.png"/>
+<title>さかたっち</title>
+<style type="text/css">
+<!--
+-->
+</style>
+</head>
+
+<body>
+<header></header>
+<h1>データがみつかりません!</h1><h2>クッキーを消してやりなおしてください!</h2>
+<div class="f1"><a href="index.html"><div class="lets"><span>とうろく画面へ!</span></div></a></div>
+<address>skip&#x40;xxxx.co.jp</address>
+<footer></footer>
+</body>
+</html>
+
+_EOS_
+exit(0)            ##プログラム終了! これがないと以降のプログラムが動いてしまう。
+end
+
+
 
 q1 = toi[0][1]
 q2 = toi[0][2]
@@ -317,7 +353,7 @@
 </div>
 <table class="state"><tr><td>name</td><td>:%s</td></tr>
 <tr><td>id</td><td>:%04d</td></tr>
-<tr><td>cal</td><td>:%s</td></tr>
+<tr><td>cara</td><td>:%s</td></tr>
 <tr><td>lv.</td><td>%d</td></tr>
 </table>
 </div>
@@ -335,22 +371,22 @@
 <p>さかたポイント:%dp</p>
 <table><tr><td>
 <form method="POST" action="gohan.rb">
-<input type="checkbox" name="hdn">ごはん!<div><br>
-<input type="radio" name="gohan" value="g1">%s:1pt<img src=%s width="16" height="16"><br>
-<input type="radio" name="gohan" value="g2">%s:3pt<img src=%s width="16" height="16"><br><br>
+<label><input type="checkbox" name="hdn">ごはん!<div><br>
+<label><input type="radio" name="gohan" value="g1">%s:1pt<img src=%s width="16" height="16"></label><br>
+<label><input type="radio" name="gohan" value="g2">%s:3pt<img src=%s width="16" height="16"></label><br><br>
 <input type="reset" value="とりけし">
 <input type="submit" value="こうかんする!"><br>
 <input type="text" name="gohan" placeholder="ひみつ の こたえ を いれてね!">:0pt
-</div></form>
+</div></label></form>
 </td><td>
 <form method="POST" action="gets.rb">
-<input type="checkbox" name="hdn">しょうひん!<div><br>
-<input type="radio" name="sho" value="s1">おちゃ:3pt<br>
-<input type="radio" name="sho" value="s2">おんせんのもと:10pt<br>
-<input type="radio" name="sho" value="s3">せんたくせんざい:20pt<br>
+<label><input type="checkbox" name="hdn">しょうひん!<div><br>
+<label><input type="radio" name="sho" value="s1">おちゃ:3pt</label><br>
+<label><input type="radio" name="sho" value="s2">おんせんのもと:10pt</label><br>
+<label><input type="radio" name="sho" value="s3">せんたくせんざい:20pt</label><br>
 <input type="reset" value="とりけし">
-<input type="submit" value="こうかんする!"></div><br>
-</span>
+<input type="submit" value="こうかんする!"></div></label><br>
+
 </form>
 </td></tr></table>
 

yatex.org