I'm trying to save/store data from a form to a text file. The problem is that the information sent from the form does not seem to be storing in the text file as whenever I enter its url the page is just empty. The code is as follows:
The simple form (database.php)
<form action = "ProcessFormData.php" method = "post"> Name <input type="text" name="name"> Age <input type="text" name="age"> <input type="submit" value="Go Go">
The php file that is supposed to transfer the form data onto the text file
<?php $name = $_POST['name']; $age = $_POST['age']; $data = "$name ¦ $age\n"; $fh = fopen("data.txt", 'a') or die ("can't open file"); fwrite($fh, $data); fclose($fh); echo 'file has been saved'; ?>
The text file is called data.txt. After doing a little googling I have set chmod 777 permissions on FTP however the data.txt file is still empty and whichever information I enter into the form (database.php) does not seem to get saved on data.txt.
What am I doing wrong here? What do I need to do to view the form data?