0

独自のゲストブックを作成するための php スクリプトを見つけました。これを販売報告用の簡単なページにしようとしました。何かが間違っているので、コードを見てください。WSoD になってしまいます。

いくつかの異なるフィールドが必要で、[保存] が押されたときにこれらを同じページに (できれば自動日付機能を使用して) 表示させます。

<html>
<head><title>Reports</title></head>
<body>
<h1>Reports</h1>
<h2>Please fill in the form below and click Save.</h2>

<form action="" method="POST">
<input type="text" name="user" placeholder="Name" />
<br />
<input type="text" name="date" placeholder="Date" />
<br />
<input type="text" name="company" placeholder="Company" />
<br />
<textarea cols="40" rows="5" name="note" placeholder="Report" wrap="virtual"></textarea>
<br />
<input type="submit" name="submit" value="Save" />
</form>
<?php

if (isset($_POST['submit'])){

$user = $_POST['user'];
$user = $_POST['date'];
$user = $_POST['company'];
$note = $_POST['note'];

if(!empty($user) && !empty($date)) && !empty($company)) && !empty($note)) {
$msg = $user . ' <br /> ' . $date . ' <br /> ' . $company . ' <br /> ' . $note;
//will open a file
$fp = fopen("report.txt","a") or die("Can't open file");
//will write to a file
fwrite($fp, $msg."\n");
fclose($fp);
}
}
?>

<h2>Old reports:</h2>
<?php
$file = fopen("report.txt", "r") or exit("Unable to open file!");
//Output a line of the file until the end is reached
while(!feof($file))
  {
  //will return each line with a break
  echo fgets($file). '<br />';
  }
fclose($file);
?> 
</body>
</html>
4

1 に答える 1