I am trying to get a simple form which will write to a file using php. But I am running into an error where whenever I try and write a value got through post, it writes '0' to the file instead of the value.
I have a form like the following:
<form method="post" action="test.php">
<input type="text" name="user" />
<input type="submit" value="submit"/>
</form>
And test.php gets the user from the form via:
$user = $_POST['user'];
I can display $user
on the page fine, and I have been able to write strings to the file using fwrite
fine as well. But whenever I fwrite($file,$user)
the only thing written is a 0
. What am I doing wrong?