I will like to save the output of the following form action in a textfile like this:
var1
var2
var3
Example form action:
<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>
Example 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);
?>
However, the output is:
var1var2var3
What could i do to fix it?