你的PHP应该看起来像这样......
<?php
if ($_POST["submit"]) {
$firstName = $_POST["firstName"];
$lastName = $_POST["lastName"];
$dormName = $_POST["dormName"];
$roomNumber = $_POST["roomNumber"];
$pizzaType = $_POST["pizzaName"];
$fp = fopen($firstName . "_" . $lastName . ".txt", "a"); // the 'a' will append to the end of the file.
fwrite($fp, "\n\n");
fwrite($fp, "First Name: $firstName\n");
fwrite($fp, "Last Name: $lastName\n");
fwrite($fp, "Dorm Name: $dormName\n");
fwrite($fp, "Room Number: $roomNumber\n");
fwrite($fp, "Pizza Type: $pizzaType\n");
fclose($fp);
}
?>
<html>
<head>
<title>test</title>
</head>
<body>
<form method="POST" id="" action="">
<input type="text" name="firstName" value="" />
<input type="text" name="lastName" value="" />
<input type="text" name="dormName" value="" />
<input type="text" name="roomNumber" value="" />
<input type="text" name="pizzaName" value="" />
<input type="submit" name="submit" value="Submit" />
</form>
</body>
</html>
注意:如果另一个同名的人再次订购,它将全部附加到同一文件的底部。
干杯