LoginSignup
3
3

More than 1 year has passed since last update.

メンタル疾患症状管理、服薬管理Webシステム(書き込み結果、ファイル出力編)

Posted at

メンタル疾患病状管理、服薬管理Webシステム(書き込み結果、ファイル出力編)のソースコードを公開いたします。

ファイル書き込み(result.php)のソースコードです。

<!--  result.php -->
<!--  メンタル疾患、服薬管理の表示プログラム -->
<!--  メンタル疾患、服薬管理システム -->
<!--  新規作成 2021/5/12 -->
<!--  作成者:乃木坂好きのITエンジニア -->


<?php
    $message = 'OK';

    $year = htmlspecialchars($_REQUEST['year']);
    $month = htmlspecialchars($_REQUEST['month']);
    $day = htmlspecialchars($_REQUEST['day']);
    $sleep = htmlspecialchars($_REQUEST['sleep']);
    $mental = htmlspecialchars($_REQUEST['mental']);
    $morning = htmlspecialchars($_REQUEST['morning']);
    $evening = htmlspecialchars($_REQUEST['evening']);
    $night = htmlspecialchars($_REQUEST['night']);
    $iraira = htmlspecialchars($_REQUEST['iraira']);
    $head_pain = htmlspecialchars($_REQUEST['head_pain']);
    $offence = htmlspecialchars($_REQUEST['offence']);
    $die = htmlspecialchars($_REQUEST['die']);
    $OD = htmlspecialchars($_REQUEST['OD']);
    $nothing = htmlspecialchars($_REQUEST['nothing']);
    $panik = htmlspecialchars($_REQUEST['panic']);
    $kanashibari = htmlspecialchars($_REQUEST['kanashibari']);
    $content = htmlspecialchars($_REQUEST['content']);

    $line = $year .  $month . $day. "\n". "睡眠度:" .  $sleep . "\n" . "気分の落ち込み度" . $mental . "\n" . "投薬管理 " . $morning . " " . $evening. " " . $night ."\n" . "あてはまる主な症状: " .$iraira . " " . $head_pain . " ". $offence . " " .$die . " " . $OD . " " .$nothing . " " .$panik . " " .$kanashibari. "\n" . "症状の詳細:" . $content . "\n" . PHP_EOL;
    file_put_contents(__DIR__ . '/articles.txt', $line, FILE_APPEND | LOCK_EX);

    require_once 'views/result.tpl.php';

書き込み結果を表示するソースコードです。(result.tpl.php)

<!--  result.tpl.php -->
<!--  結果表示ののテンプレートプログラム -->
<!--  メンタル疾患、服薬管理システム -->
<!--  新規作成 2021/5/12 -->
<!--  作成者:乃木坂好きのITエンジニア -->


<!DOCTYPE html>
<html lang='ja'>
    <?php include('header.inc.php'); ?>
    <body>

        <h1>書き込みました</h1>
        <p><?= $message ?></p>

        <p>
            <?php
                if(isset($year)) {
                    echo $year . ', ';
                }

                if(isset($month)) {
                    echo $month . ', ';
                }

                if(isset($day)) {
                    echo $day . ', ';
                }

                if(isset($sleep)) {
                    echo $sleep . ', ';
                }

                if(isset($mental)) {
                    echo $mental;
                }

                if(isset($morning)) {
                    echo $morning;
                }

                if(isset($evening)) {
                    echo $evening;
                }

                if(isset($night)) {
                    echo $night;
                }

                if(isset($iraira)) {
                    echo $iraira;
                }

                if(isset($head_pain)) {
                    echo $head_pain;
                }

                if(isset($offence)) {
                    echo $head_pain;
                }

                if(isset($die)) {
                    echo $die;
                }

                if(isset($OD)) {
                    echo $die;
                }

                if(isset($nothing)) {
                    echo $nothing;
                }

                if(isset($panic)) {
                    echo $nothing;
                }

                if(isset($kanashibari)) {
                    echo $kanashibari;
                }

                if(isset($content)) {
                    echo $content;
                }

            ?>
        </p>

        <form action='mental.php' method='get'>
            <button type='submit' id="submit">戻る</button>
        </form>

        <?php include('footer.inc.php'); ?>
    </body>
</html>
3
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
3