php
1<html> 2 3 4 <form action="2-115.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-1_Yusuke115.txt'); 23 24 25?> 26 27 28 29 30<?php 31 32 33date_default_timezone_set('Asia/Tokyo'); 34 35$filename = 'mission_2-1_Yusuke115.txt'; 36 37$line = file($filename); 38 39$number = count($line) + 1; 40 41 42?> 43 44 45<?php 46 47 48$fp = fopen($filename, "a"); 49 50if($_POST["name"] and $_POST["coment"]) 51 52{fwrite($fp, $number."<>".$_POST['name']."<>".$_POST['coment']."<>".date("Y年m月d日 H:i:s"),"<br>"); 53 54fclose($fp);} 55 56 57?> 58
フォームとからのテキストファイルは作成できたが、全然テキストファイルにユーザーが書いた文字列が書き込まれない。