|
-
Feb 6th, 2003, 03:58 PM
#1
Thread Starter
Addicted Member
Noobie Help (resolved)
Ok I'm trying to make a page the will import the text from a text file (news.txt) and put it into a text area. Once the text is edited the user clicks save and it will then save the text file. How can this be done?
all i know is that if i did
$blah = readfile("news.txt");
it will get the file text. but then how do i go about putting it into a text area and the save button?
Last edited by Coolone770; Feb 8th, 2003 at 04:21 PM.
-
Feb 6th, 2003, 09:39 PM
#2
Stuck in the 80s
Off the top of my head:
Code:
if (isset($_POST['submit'])) {
$file = fopen("filename.txt", "w");
fwrite($file, $_POST['contents']);
fclose($file);
} else {
$contents = implode("\n", file("filename.txt"));
echo '<form action="yourpage.php" method="post">
<textarea name="contents">' . $contents . '</textarea><br>
<input type="submit" name="submit" value="Save">
</form>';
}
Something like that. Of course, permissions have to be set for the directory/file.
-
Feb 7th, 2003, 03:51 PM
#3
Thread Starter
Addicted Member
how about i make the text area bigger? other then that it works good. thanks
figured that out with rows= cols= heh
Last edited by Coolone770; Feb 7th, 2003 at 04:59 PM.
-
Feb 7th, 2003, 04:24 PM
#4
Thread Starter
Addicted Member
Hmm found a problem i think.. I put in what i want, hit save. I goto view the page that gets the info from the text file and its not updated. I tried a couple things and figured out that in order to make it update, i had to put in the info i wanted hit save, browse to news.txt, hit refresh, and then it will update on the page.
http://team-ly.com
The flash file on this page is what grabs the information from the text file.
-
Feb 8th, 2003, 04:20 PM
#5
Stuck in the 80s
Originally posted by Coolone770
how about i make the text area bigger? other then that it works good. thanks
figured that out with rows= cols= heh
You could also do:
Code:
<textarea name="contents" style="width: 150px; height: 100px;">' . $contents . '</textarea>
This lets you specify height/width in pixels, rather than in columns and rows.
Originally posted by Coolone770
Hmm found a problem i think.. I put in what i want, hit save. I goto view the page that gets the info from the text file and its not updated. I tried a couple things and figured out that in order to make it update, i had to put in the info i wanted hit save, browse to news.txt, hit refresh, and then it will update on the page.
http://team-ly.com
The flash file on this page is what grabs the information from the text file.
I have no idea what you're talking about...
-
Feb 8th, 2003, 04:21 PM
#6
Thread Starter
Addicted Member
hmm. I guess i will have to deal with the problem. .. thanks for the help man.
-
Feb 8th, 2003, 04:57 PM
#7
Frenzied Member
sounds like it is getting stored in your cache if you have to hit refresh everytime. use the meta tag no-cache so it won't do that. but not sure if it works in IE.
-
Feb 8th, 2003, 05:00 PM
#8
Thread Starter
Addicted Member
how would i do that phpman? im really a noob at this stuff
-
Feb 8th, 2003, 05:03 PM
#9
Frenzied Member
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
might not work in IE and that goes between your head tags in your file.
-
Feb 8th, 2003, 05:04 PM
#10
Thread Starter
Addicted Member
-
Feb 8th, 2003, 05:13 PM
#11
Thread Starter
Addicted Member
Thanks, that did the job!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|