Triple X 0 Report post Posted September 29, 2004 (edited) How can I create a php page that lets me edit a file? I mean edit it on the page so i don't have to go into cpanel to do it, I wanna do it so I can edit my "news" file from a page(which i will duh p/w protect).Any help would be awesome. Edited September 29, 2004 by Triple X (see edit history) Share this post Link to post Share on other sites
truvu17 0 Report post Posted September 30, 2004 What kind of data management application are you using to run your website?Im not very sure what you mean, but if you using any php data management application, maybe make a news module with admin permission to change and users to view only. I believe they already have news module out there for most applications like php-nuke, mambo, dotnetnuke. And all you have to do is go to admin back-end and write whatever you want in news section and select who could view and edit the file. Share this post Link to post Share on other sites
Spectre 0 Report post Posted September 30, 2004 You could use something like this: <?php[br][/br]$newsfile = "news-file";[br]// Assuming you are using a flat-file to store your news,[/br]// replace 'news-file' with the path to it[br][/br]if(!isset($_GET['act'])) {[br] $act = "view";[/br]} else {[br] $act = $_GET['act'];[/br]}[br][/br]if(isset($_POST['news'])) {[br] $file = fopen($newsfile,"w");[/br] $data = $_POST['news'];[br] fputs($file,$data);[/br] fclose($file);[br] echo "News saved.";[/br] exit;[br]}[/br] [br][/br]if($act == "edit") {[br] $data = file_get_contents($newsfile);[/br] echo "<form name=\"editnews\" method=\"post\" action=\"script.php\">\n";[br] echo "<textarea name=\"news\">" . $data . "</textarea>\n";[/br] echo "<input type=\"submit\" name=\"save-news\" value=\"Save\"></form>";[br]} elseif($act == "view") {[br] $data = file_get_contents($newsfile);[/br] echo $newsfile;[/br]}[br][/br]?> Note that I just threw this script together for the sake of this post, and haven't tested it yet. Feel free to use / edit it as you wish. Share this post Link to post Share on other sites
X3r0X 0 Report post Posted September 30, 2004 Wow, ur really good at php. Consider writing a tutorial? Share this post Link to post Share on other sites
Triple X 0 Report post Posted October 1, 2004 One: what is a "flat file" like only test or w/e? if so then yes I am using one.It didn't work....I copyed the code saved it and all the page had was the filename, nothing else no textarea no nothing sept the filename...thanks anyway. Share this post Link to post Share on other sites