Reputation: 663
I am trying to write into a file work/log_file.txt upon submitting a page work/login.php. But the contents (form values from login.php) are not getting written. This is the code I used
if(isset($_POST['submitform'])){
$file="log_file.txt";
$open = fopen($file, "a+"); //open the file,
fwrite($open, "Name: " .$_POST['user'] . "\n"); //print / write the name.
fwrite($open, "Colour: ". $_POST['color'] . "\n"); //print / write the colour.
fclose($open); //close the opened file
}
I am running the code in a test server. I just saved file as log_file.txt in local and then uploaded it to test server folder work ,and run the code. But not getting written to the file
Upvotes: 0
Views: 93
Reputation: 62924
Does the web server process have write permissions for the file?
Tip that will serve you well: turn on all errors while debugging:
ini_set('display_errors',1);
error_reporting(E_ALL);
Any number of things could be off, but you'll never know unless you see the notices and warnings.
Upvotes: 1