RE: [PHP]I'm puzzled. TEXTAREA related.

From: Date: Thu, 12 Jul 2001 15:29:35 +0000
Subject: RE: [PHP]I'm puzzled. TEXTAREA related.
Groups: php.general 
Request: Send a blank email to php-general+get-57601@lists.php.net to get a copy of this message
> -----Original Message----- > From: Chris Cocuzzo [mailto:cuzo@mediaone.net] > 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 (roedelm@letu.edu) || "There cannot be a crisis next week. Systems Programmer / WebMaster || My schedule is already full." LeTourneau University || -- Henry Kissinger

« previous php.general (#57601) next »