我被困住了。一直试图解决这个问题。这个例子几乎与老师相同......我不明白...... html是here。它的简单设置安排。它不会正确写入文件。帮助
编辑:它不会将变量写入文件。我可以让它写文本,而不是变量。希望澄清。
<?php
/* Create folder for data */
if (is_dir('schedule'))
chdir('schedule');
else
{mkdir('schedule');
chdir ('schedule');}
/* Variable Declaration */
/* Employee 1 */
$sunStart1=$_POST['sunStart1'];
$sunEnd1=$_POST['sunEnd1'];
$monStart1=$_POST['monStart1'];
$monEnd1=$_POST['monEnd1'];
$tuesStart1=$_POST['tuesStart1'];
$tuesEnd1=$_POST['tuesEnd1'];
$wedStart1=$_POST['wedStart1'];
$wedEnd1=$_POST['wedEnd1'];
$thurStart1=$_POST['thurStart1'];
$thurEnd1=$_POST['thurEnd1'];
$friStart1=$_POST['friStart1'];
$friEnd1=$_POST['friEnd1'];
$satStart1=$_POST['satStart1'];
$satEnd1=$_POST['satEnd1'];
/* Employee 2 */
$sunStart2=$_POST['sunStart2'];
$sunEnd2=$_POST['sunEnd2'];
$monStart2=$_POST['monStart2'];
$monEnd2=$_POST['monEnd2'];
$tuesStart2=$_POST['tuesStart2'];
$tuesEnd2=$_POST['tuesEnd2'];
$wedStart2=$_POST['wedStart2'];
$wedEnd2=$_POST['wedEnd2'];
$thurStart2=$_POST['thurStart2'];
$thurEnd2=$_POST['thurEnd2'];
$friStart2=$_POST['friStart2'];
$friEnd2=$_POST['friEnd2'];
$satStart2=$_POST['satStart2'];
$satEnd2=$_POST['satEnd2'];
/* Make data file */
$schedule = fopen('schedule.txt', 'w');
fwrite($schedule, "$sunStart1\n");
fwrite($schedule, "$sunEnd1 \n");
fwrite($schedule, "$monStart1 \n");
fwrite($schedule, "$monEnd1 \n");
fwrite($schedule, "$tuesStart1 \n");
fwrite($schedule, "$tuesEnd1 \n");
fwrite($schedule, "$wedStart1 \n");
fwrite($schedule, "$wedEnd1 \n");
fwrite($schedule, "$thurStart1 \n");
fwrite($schedule, "$thurEnd1 \n");
fwrite($schedule, "$friStart1 \n");
fwrite($schedule, "$friEnd1 \n");
fwrite($schedule, "$satStart1 \n");
fwrite($schedule, "$satEnd1 \n");
fwrite($schedule, "$sunStart2 \n");
fwrite($schedule, "$sunEnd2 \n");
fwrite($schedule, "$monStart2 \n");
fwrite($schedule, "$monEnd2 \n");
fwrite($schedule, "$tuesStart2 \n");
fwrite($schedule, "$tuesEnd2 \n");
fwrite($schedule, "$wedStart2 \n");
fwrite($schedule, "$wedEnd2 \n");
fwrite($schedule, "$thurStart2 \n");
fwrite($schedule, "$thurEnd2 \n");
fwrite($schedule, "$friStart2 \n");
fwrite($schedule, "$friEnd2 \n");
fwrite($schedule, "$satStart2 \n");
fwrite($schedule, "$satEnd2 \n");
fclose ($schedule);
?>
答案 0 :(得分:3)
您的表单方法没有正确设置语法...
你有
<form action="lab5.php" method"POST">
应该是
<form action="lab5.php" method="POST">
另外你的表单结构也不正确......
我会将<form>
放在<table>
之前,然后在</form>
</table>