webent Posted July 13, 2008 Share Posted July 13, 2008 Hi, I was wondering if someone could tell me what I'm doing wrong or if there is a better way to go about achieving my desired goal... I'm trying to allow users to modify external .css pages... They select the desired style sheet from a dropdown that has all of the css files in that directory, it opens the style sheet using fopen and fread, places the content in a form textarea... This all works great up to this point, but when they make changes, they don't save... So my first thought was to check CHMOD to make sure that they were in fact still changed to 666, they were, so I tried 777, still no go... Here's my code thus far... $myFile = "style-sheet.css"; //example $fh = fopen($myFile, 'r'); if (isset($_POST['submitChanges'])) { $stringData = $_POST['newSheet']; fwrite($fh, $stringData); } $theData = fread($fh, filesize($myFile)); echo '<form action="' . $_SERVER['php_self'] . '" method="post"> <textarea name="newSheet" cols="100" rows="100">' . $theData . '</textarea> <input type="submit" name="submitChanges" value="Submit Changes"> </form>'; fclose($fh); Quote Link to comment Share on other sites More sharing options...
webent Posted July 13, 2008 Author Share Posted July 13, 2008 Ok, I got it... stupid mistake on my part, I needed to changed fopen to write in the write part of the code... here's the final code... if (isset($_POST['submitChanges'])) { $myFile = "style-sheet.css"; $fh = fopen($myFile, 'w'); $stringData = $_POST['newSheet']; fwrite($fh, $stringData); fclose($fh); } $myFile = "style-sheet.css"; $fh = fopen($myFile, 'r'); $theData = fread($fh, filesize($myFile)); echo '<form action="' . $_SERVER['php_self'] . '" method="post"> <textarea name="newSheet" cols="100" rows="100">' . $theData . '</textarea> <input type="submit" name="submitChanges" value="Submit Changes"> </form>'; fclose($fh); Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.