Okay, so I'm working on one of my sites and I'm wanting to save a text field to a text file on my server. I found this code:
And then modded it to my liking.
But noticed that it doesn't save the previous content, it only overwrites it. So I figured I'd try and fix it like this:
Now it isn't even saving, what am I doing wrong exactly?
Also, I'm not very good at PHP, I miss a lot of functions and generally just suck at it, so it might be a stupid problem in the script.
Thanks to anyone who replies.
PHP:
<?php
$content = $_POST['content'];
$file = "file.txt";
$Saved_File = fopen($file, 'w');
fwrite($Saved_File, $content);
fclose($Saved_File);
?>
And then modded it to my liking.
But noticed that it doesn't save the previous content, it only overwrites it. So I figured I'd try and fix it like this:
PHP:
<?php
header("Location: gotourl.com");
$content = $_POST['content'];
$file = "file.txt";
$old_content = file_get_contents($file);
fwrite($file, $content."\n".$old_content);
fclose($file);
?>
Now it isn't even saving, what am I doing wrong exactly?
Also, I'm not very good at PHP, I miss a lot of functions and generally just suck at it, so it might be a stupid problem in the script.
Thanks to anyone who replies.