> -----Original Message-----
> From: Chris Cocuzzo [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, July 11, 2001 5:40 PM
> To: PHP General List (E-mail)
> Subject: [PHP]I'm puzzled. TEXTAREA related.
> 
> 
> hey-
> 
> i have a page containing a form with a textarea field. The 
> first part of the page is a quick IP check to make sure the
> request is coming from my computer. Here's the code I'm
> confused about:
> 
> 
> <textarea rows="25" cols="80" name="news_info" [snip]>
> <?php
> readfile("lib/news_file.dat");
> ?>
> </textarea>
> <br><br>
> <input type="submit" name="submit">&nbsp;&nbsp;
> <input type="reset" name="reset"><br>
> 
> -this part above reads in data from the news file and it's 
> put in between the textarea tags, so editing it is easier,
> then there is this part:
> 
> <?php
> }
> 
> if($submit)
> {
>     $fileh = fopen("lib/news_file.dat", "w");
>     fwrite($fileh, $news_info);
>     fclose($fileh);
> }
> ?>

Assuming the order of events in your script is as described above,
here's what's happening:

1st request: 
        script displays textarea (blank, or with old contents)
        $submit is unset, so no further action

2nd request:
        script displays textarea (blank, or with old contents)
        $submit is set, so *now* we write the new data out to the file

3rd request:
        script displays textarea with updated contents

So...I'd expect the answer is to make sure you're updating the file
*before* you look at its contents.


---
Mark Roedel ([EMAIL PROTECTED])  ||  "There cannot be a crisis next week.
Systems Programmer / WebMaster  ||   My schedule is already full."
     LeTourneau University      ||                    -- Henry Kissinger


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to