Example #1
0
require_once "lib_login.php";
error_reporting(E_ALL);
session_start();
// ログインしていなければログインページに移動します
if (isLogin() == false) {
    header("location: login_form.php");
    exit;
}
// 日付がGETで受け取れているか判定します
// GETできていなければマイページに移動します
if (!isset($_GET["date"])) {
    $_SESSION["message"] = "日付が指定されていません";
    header("location: mypage.php");
    exit;
}
// 日記の情報を取得します
// 取得できなければマイページに移動します
$diary = getDiaryData($_SESSION["person_id"], $_GET["date"]);
if ($diary == false) {
    $_SESSION["message"] = "指定された日記は存在しません";
    header("location: mypage.php");
    exit;
}
// 日記の情報に置換する文字列を指定します
$strings = array("name", "create_day", "post");
$replaces = array();
foreach ($strings as $string) {
    $replaces[$string] = isset($diary[$string]) ? $diary[$string] : null;
}
// diary.phpを表示します
displayFile("diary.html", $replaces);
Example #2
0
<?php

// マイページを表示します
require_once "lib_DB.php";
require_once "lib_display.php";
require_once "lib_login.php";
error_reporting(E_ALL);
session_start();
// ログインしていなければログインページに移動します
if (isLogin() == false) {
    header("location: login_form.php");
    exit;
}
// セッションの値に置換する文字列を指定します
$strings = array("message", "name");
$replaces = array();
foreach ($strings as $string) {
    $replaces[$string] = isset($_SESSION[$string]) ? $_SESSION[$string] : null;
}
// 日記の情報を取得します
$diaries = getDiaryData($_SESSION["person_id"]);
// 日記の情報に繰り返し置換する行を指定します
$loop = array("4" => $diaries);
// mypage.htmlを表示します
displayFile("mypage.html", $replaces, $loop);
// メッセージを削除します
unset($_SESSION["message"]);