php
1<html> 2 3 4 <form action="2-202.php" method="post"> 5 6 7お名前: <input type="text" name="name"><br> 8 9コメント: <input type="text" name="coment"><br> 10 11<input type="submit" value="送信"> 12 13 14</form> 15 16 17</html> 18 19 20<?php 21 22touch('mission_2-2_02.txt'); 23 24 25?> 26 27 28 29 30<?php 31 32 33date_default_timezone_set('Asia/Tokyo'); 34 35$filename = 'mission_2-2_02.txt'; 36 37$lines = file($filename); 38 39$number = 1 + count(++$lines); 40 41 42?> 43 44 45<?php 46 47 48if(isset($_POST['name']) and isset($_POST['name'])) 49 50 51 52 53{$fp = fopen($filename, "a"); 54 55fwrite($fp, $number."<>".$_POST['name']."<>".$_POST['coment']."<>".date("Y年m月d日 H:i:s"). "\n"); 56 57fclose($fp); 58 59 60 61 62foreach($lines as $line); 63 64{$portion = explode( "<>", $line); 65 66echo <pre>$portion[0] $portion[1] $portion[2] $portion[3] $portion[4] ,"\n"</pre>}} 67 68 69 70?> 71 72
https://teratail.com/help/avoid-asking https://teratail.com/help/question-tips