Jump to content



Welcome to KnowledgeSutra - Dear Guest , Please Register here to get Your own website. - Ask a Question / Express Opinion / Reply w/o Sign-Up!
- - - - -

Need help...


4 replies to this topic

#1 Triple X

    Super Member

  • Kontributors
  • PipPipPipPipPipPipPipPipPip
  • 390 posts
  • Location:No Where
  • Interests:PS2, computer, music, eh...stuff.

Posted 29 September 2004 - 03:11 PM

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 by Triple X, 29 September 2004 - 04:30 PM.


#2 truvu17

    Member [Level 1]

  • Kontributors
  • PipPipPipPip
  • 53 posts

Posted 30 September 2004 - 06:53 AM

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.

#3 Spectre

    Privileged Member

  • Kontributors
  • PipPipPipPipPipPipPipPipPip
  • 873 posts

Posted 30 September 2004 - 07:18 AM

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.

#4 X3r0X

    ^^ Thats me ^^

  • Kontributors
  • PipPipPipPipPipPipPipPipPip
  • 528 posts

Posted 30 September 2004 - 09:19 AM

Wow, ur really good at php. Consider writing a tutorial?

#5 Triple X

    Super Member

  • Kontributors
  • PipPipPipPipPipPipPipPipPip
  • 390 posts
  • Location:No Where
  • Interests:PS2, computer, music, eh...stuff.

Posted 01 October 2004 - 01:44 AM

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.




Reply to this topic


This post will need approval from a moderator before this post is shown.

  


1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users