我想将以下表单操作的输出保存在这样的文本文件中:
var1
var2
var3
示例表单操作:
<form action="myform.php" method="post">
<input type="hidden" name="var1" value="var1">
<input type="hidden" name="var2" value="var2">
<input type="hidden" name="var3" value="var3">
<input type="submit" name="formSubmit" value="Submit">
</form>
示例 myform.php
<?php
$fs = fopen("mydata.txt","w");
fwrite($fs,$_POST['var1']);
fwrite($fs, "\n");
fwrite($fs,$_POST['var2']);
fwrite($fs, "\n");
fwrite($fs,$_POST['var3']);
fwrite($fs, "\n");
fclose($fs);
?>
但是,输出是:
var1var2var3
我能做些什么来解决它?