RE: [PHP]I'm puzzled. TEXTAREA related.
-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 brbr input type=submit name=submitnbsp;nbsp; input type=reset name=resetbr -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]
[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 style=BACKGROUND-COLOR: rgb(31,31,31); BORDER-BOTTOM: rgb(0,0,0) 1px solid; BORDER-LEFT: rgb(0,0,0) 1px solid; BORDER-RIGHT: rgb(0,0,0) 1px solid; BORDER-TOP: rgb(0,0,0) 1px solid; COLOR: rgb(255,255,255); FLOAT: none; FONT-FAMILY: verdana; FONT-SIZE: 8pt; LETTER-SPACING: normal; LINE-HEIGHT: normal; MARGIN-LEFT: 0px; PADDING-BOTTOM: 1px; PADDING-TOP: 1px; TEXT-ALIGN: left; TEXT-INDENT: 0px; VERTICAL-ALIGN: middle ?php readfile(lib/news_file.dat); ? /textarea brbr input type=submit name=submitnbsp;nbsp; input type=reset name=resetbr -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); } ? - that checks if the submit button was pressed, and if so, it writes the data from the textarea to the file - the problem I noticed was that if I submit with something in the textarea, it doesn't display when the page loads again, which is weird, because the action of the form is directed to the same page. but, if I press submit an addditional time, the data I entered in the first time comes up...I don't understand why it's not immediately showing up, since it does write to the file when submit is pressed please help! -- 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]
Re: [PHP]I'm puzzled. TEXTAREA related.
On Thu, 12 Jul 2001 08:09, Chris Cocuzzo wrote: 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 style=BACKGROUND-COLOR: rgb(31,31,31); BORDER-BOTTOM: rgb(0,0,0) 1px solid; BORDER-LEFT: rgb(0,0,0) 1px solid; BORDER-RIGHT: rgb(0,0,0) 1px solid; BORDER-TOP: rgb(0,0,0) 1px solid; COLOR: rgb(255,255,255); FLOAT: none; FONT-FAMILY: verdana; FONT-SIZE: 8pt; LETTER-SPACING: normal; LINE-HEIGHT: normal; MARGIN-LEFT: 0px; PADDING-BOTTOM: 1px; PADDING-TOP: 1px; TEXT-ALIGN: left; TEXT-INDENT: 0px; VERTICAL-ALIGN: middle ?php readfile(lib/news_file.dat); ? /textarea brbr input type=submit name=submitnbsp;nbsp; input type=reset name=resetbr -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); } ? - that checks if the submit button was pressed, and if so, it writes the data from the textarea to the file - the problem I noticed was that if I submit with something in the textarea, it doesn't display when the page loads again, which is weird, because the action of the form is directed to the same page. but, if I press submit an addditional time, the data I entered in the first time comes up...I don't understand why it's not immediately showing up, since it does write to the file when submit is pressed please help! You aren't setting a value for submit, so you might be better checking for either isset($submit) or !empty($submit) rather than if($submit). Otherwise try assigning a value to submit in the input tag. -- David Robley Techno-JoaT, Web Maintainer, Mail List Admin, etc CENTRE FOR INJURY STUDIES Flinders University, SOUTH AUSTRALIA Avoid temporary variables and strange women. -- 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]