marcus Posted May 20, 2007 Share Posted May 20, 2007 I made a file editor, the only problem is that, when I try to change the file contents it just added that content I changed it to the actual file content. Say: if file abc.php's content was: hello and i wanted to change the WHOLE file to say goodbye and when I hit save, it would make the contents: hellogoodbye CODE: edit.php <?php $loadcontent = $_GET['page']; if ( isset ( $_POST['savecontent'] ) && trim ( $_POST['savecontent'] ) != '' ) { $content = $_POST['savecontent']; $fp = @fopen ( $loadcontent, 'w' ); if ( $fp ) { fwrite ( $fp, $content ); fclose ( $fp ); } } else { $fp = @fopen ( $loadcontent, 'r' ); $content = htmlspecialchars ( fread ( $fp, filesize ( $loadcontent ) ) ); fclose ( $fp ); } ?> <form method=post action="change.php"> <input type=hidden name=filename value="<?=$_GET ?>"> savecontent <textarea name="theText" cols="70" rows="25"><?=$content;?></textarea> <br> <input type="submit" name="save_file" value="Save"> </form> change.php <? ob_start(); $filename = $_POST[filename]; $theText = $_POST[theText]; $theText = stripslashes($theText); $data = fopen($filename, "a"); fwrite($data,$theText); fclose($data); echo "File created or updated"; sleep(3); header("Location: edit.php?page=$filename"); ob_end_flush(); ?> Link to comment https://forums.phpfreaks.com/topic/52255-file-editor-help/ Share on other sites More sharing options...
marcus Posted May 24, 2007 Author Share Posted May 24, 2007 4 days later Link to comment https://forums.phpfreaks.com/topic/52255-file-editor-help/#findComment-261095 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.