Results 1 to 11 of 11

Thread: Noobie Help (resolved)

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Nov 2001
    Posts
    154

    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.

  2. #2
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    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.
    My evil laugh has a squeak in it.

    kristopherwilson.com

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Nov 2001
    Posts
    154
    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.

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Nov 2001
    Posts
    154
    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.

  5. #5
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    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...
    My evil laugh has a squeak in it.

    kristopherwilson.com

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Nov 2001
    Posts
    154
    hmm. I guess i will have to deal with the problem. .. thanks for the help man.

  7. #7
    Frenzied Member
    Join Date
    Nov 1999
    Posts
    1,337
    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.

  8. #8

    Thread Starter
    Addicted Member
    Join Date
    Nov 2001
    Posts
    154
    how would i do that phpman? im really a noob at this stuff

  9. #9
    Frenzied Member
    Join Date
    Nov 1999
    Posts
    1,337
    <META HTTP-EQUIV="Pragma" CONTENT="no-cache">

    might not work in IE and that goes between your head tags in your file.

  10. #10

    Thread Starter
    Addicted Member
    Join Date
    Nov 2001
    Posts
    154
    ill try that right now

  11. #11

    Thread Starter
    Addicted Member
    Join Date
    Nov 2001
    Posts
    154
    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
  •  



Click Here to Expand Forum to Full Width