Reputation: 39
I'm trying to create a website for a college assignment and i'm having issues getting my three text fields to submit to my text document. I managed to get it to send the first one over by simply putting $_POST['des1']
and sure enough it worked perfectly. However, when I attempt to make it send over all three it doesn't work. What am I missing?
<?php
$myFile=fopen("Observation.txt","w") or exit("Can’t open file!");
fwrite($myFile, $_POST['des1'], $_POST['act1'], $_POST['date1']."\r\n");
fclose($myFile);
?>
Upvotes: 0
Views: 23
Reputation: 15609
It's because fwrite()
only takes a max of 3 arguments, but only 2 are necessary.
If you want to write it to the file, the second argument has to be the only text being written to that file.
You currently have a few ,
separating the current fields, which fwrite
will treat like more arguments and get confused.
It needs to be something like this:
$string = $_POST['des1'].$_POST['act1'].$_POST['date1']."\r\n";
fwrite($myFile, $string);
Upvotes: 1