親フォルダ タブ
01.<?php
02.session_cache_limiter('nocache');
03.session_start();
04.?>
05.<!DOCTYPE html>
06.<html>
07.<head>
08.<meta content="width=device-width initial-scale=1.0 minimum-scale=1.0 maximum-scale=1.0 user-scalable=no" name="viewport">
09.<meta charset="UTF-8">
10.<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.1/css/bootstrap.css">
11.</head>
12.<body>
13. 
14.<form>
15.学籍番号 <input type="text" name="r101">
16.<input type="submit" name="send" value="送信">
17.</form>
18. 
19.<pre>
20.<?php
21. 
22.$target = "log/data_" . session_id() . ".txt";
23. 
24.if ( file_exists( $target ) ) {
25.    $text = @file_get_contents( $target );
26.}
27.else {
28.    $text = "";
29.}
30. 
31.// 現在の内容を一番前に置いたテキストを作成する
32.$text = $_GET["r101"] . "\r\n" . $text;
33. 
34.// テキストをそのまま書き込む
35.file_put_contents( $target, $text );
36. 
37.// 全てを表示
38.print file_get_contents( $target );
39. 
40.?>
41.</pre>
42. 
43.</body>
44.</html>
ファイルの読込みと書き込み部分の行数が多くなって来たので、関数として別の場所で記述したほうが可読性が良くなります