コード例 #1
0
ファイル: schedule.php プロジェクト: koguma22/public
<?php

require "CalendarDB.php";
try {
    $dbh = new CalendarDB();
} catch (Exception $e) {
    die("カレンダーDBに繋がらない (" . $e->getMessage() . ")");
}
if (isset($_POST["ok"]) || isset($_POST["cancel"])) {
    $year = $_POST["y"];
    $month = $_POST["m"];
    $day = $_POST["d"];
    $item = $_POST["item"];
    if (isset($_POST["ok"])) {
        $dbh->set_schedule($year, $month, $day, $item);
    }
    $url = "calendar.php?year={$year}&month={$month}";
    header("location: {$url}");
    exit;
}
function check_params($y, $m, $d)
{
    if (!ctype_digit("{$y}")) {
        return "年 '{$y}' に数字ではない文字があります";
    }
    if (!ctype_digit("{$m}")) {
        return "月 '{$m}' に数字ではない文字があります";
    }
    if (!ctype_digit("{$d}")) {
        return "日 '{$d}' に数字ではない文字があります";
    }