《PHP言語 /guest_input.php》
<html>《PHP言語 /guest_write.php》
<?php
$file=fopen("guest.dat","a");
flock($file,LOCK_EX);
$line =date("Y年 m月 d日 H:i:s")."\t";
$line.=$_POST['name']."\t";
$line.=$_POST['message']."\t";
fputs($file,$line."\n");
flock($file,LOCK_UN);
fclose($file);
header("Location: guest_input.php");⇒require_once("guest_input.php");に変更
《PHP言語 /guest_read.php》
<html>
<head>
<title>ゲストブック</title>
</head>
<body>
<h1 style="background:#cccccc">ゲストブック(閲覧)</h1>
<?php
$file=fopen("guest.dat","r");
while($row=fgetcsv($file,1024,"\t")){
?>
<ol>
<li>お名前:<?php print($row[1]); ?></li>
<li>メッセージ:<?php print($row[2]); ?></li>
<li>書き込み日時:<?php print($row[0]); ?></li>
</ol>
<hr />
<?php
}
fclose($file);
?>
</body>
</html>