Hello everyone. I am working on a site that has a backend allowing the client to use a rich text editor to change the content of her pages. The editor page has a form that looks like this:
<form name="edit" method="post" action="processedit.php"> <textarea name="editor" id="editor" cols="50" rows="10"> <?php echo $content; ?> </textarea> <input type="hidden" name="pathToFile" value="index" /> <input type="submit" value="Save" /> </form>
And the action sends the form to the processedit.php shown here:
<?php $data = $_POST['editor']; $path = $_POST['pathToFile']; $file = "includes/" . $path . ".inc"; $Handle = fopen($file, 'w+') or die("can't open file"); fwrite($Handle, $data); fclose($Handle); echo 'Page saved. Click <a href="edit' . $path . '.php">Here</a> to return.'; ?>
The problem is that if I leave the or die command in, I get the error that the file cannot be opened. If I take out the or die line and echo $path, the path to the file comes through correctly. If I echo $data the text that was there originally comes through, but not any of the changes I made.
Anyone have any ideas as to why the fopen function is not working?
Thanks for all the help!