Textarea to road a text file

Textarea to road a text file

am 28.10.2009 15:39:58 von Jean Lee

I want to use Textarea as the text-file viewer and editor of my homepage.
But Textarea doesn't work exactly as i intended.
In sometimes, TextArea doesn't show up
and moreover the some parts of the file are displayed(rendered) in browser
without TextArea!




--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

RE: Textarea to road a text file

am 28.10.2009 19:52:54 von Jay Blanchard

[snip]I want to use Textarea as the text-file viewer and editor of my
homepage. But Textarea doesn't work exactly as i intended.
In sometimes, TextArea doesn't show up and moreover the some parts of
the file are displayed(rendered) in browser without TextArea![/snip]

Not enough information to complete your....request?=20

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: Textarea to road a text file

am 28.10.2009 19:59:43 von Andrew Ballard

On Wed, Oct 28, 2009 at 10:39 AM, Jean Lee wrote:
> I want to use Textarea as the text-file viewer and editor of my homepage.
> But Textarea doesn't work exactly as i intended.
> In sometimes, TextArea doesn't show up
> and moreover the some parts of the file are displayed(rendered) in browser
> without TextArea!
>
>
>
>

It sounds like you are not escaping the value that appears inside the
textarea tags.



Andrew

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: Textarea to road a text file

am 29.10.2009 00:20:32 von Jean Lee

Thank you, Jay Blanchard and Andrew Ballard!!!

Could you explain what was my fault concerned about this case?
Thanks in advance!
My codes were


.....<br /> <body>..............<br /> <br /> <?php<br /> <br /> $handle = fopen("./menu.php", "r");<br /> $contents = "";<br /> <br /> if ($handle) {<br /> while (!feof($handle)) {<br /> $buffer = fgets($handle);<br /> <br /> $contents = $contents . $buffer;<br /> }<br /> fclose($handle);<br /> }<br /> <br /> echo "<textarea cols=80 rows=30>" . $contents . "</textarea>";<br /> <br /> ?><br /> <br /> </body><br /> </html><br /> <br /> <br /> <br /> ""Jay Blanchard"" <jblanchard@pocket.com> wrote in message <br /> news:31454D514FF9A949B1FDFE294D5D1D80080142@ygex01wal.onecal l.local...<br /> [snip]I want to use Textarea as the text-file viewer and editor of my<br /> homepage. But Textarea doesn't work exactly as i intended.<br /> In sometimes, TextArea doesn't show up and moreover the some parts of<br /> the file are displayed(rendered) in browser without TextArea![/snip]<br /> <br /> Not enough information to complete your....request? <br /> <br /> <br /> <br /> -- <br /> PHP General Mailing List (http://www.php.net/)<br /> To unsubscribe, visit: http://www.php.net/unsub.php</p> </article> <article> <h2>Re: Textarea to road a text file</h2><span>am 29.10.2009 10:49:27 von Skylinux</span> <p>Jean Lee wrote:<br /> > Could you explain what was my fault concerned about this case?<br /> > <?php<br /> > <br /> > $handle = fopen("./menu.php", "r");<br /> > $contents = "";<br /> > <br /> > if ($handle) {<br /> > while (!feof($handle)) {<br /> > $buffer = fgets($handle);<br /> > <br /> > $contents = $contents . $buffer;<br /> > }<br /> > fclose($handle);<br /> > }<br /> > <br /> > echo "<textarea cols=80 rows=30>" . $contents . "</textarea>";<br /> > ?><br /> <br /> As Andrew pointed out, you need to use htmlspecialchars()<br /> echo "<textarea cols=80 rows=30>" .htmlspecialchars($contents). <br /> "</textarea>";<br /> <br /> The reason for that is because the text may contain html control <br /> characters like <>&'" which the browser will attempt to interpret.<br /> <br /> http://php.net/htmlspecialchars<br /> <br /> I usually use htmlentities() instead<br /> http://de.php.net/manual/en/function.htmlentities.php<br /> <br /> -- <br /> John<br /> Those willing to give up a little liberty for a little security<br /> deserve neither security nor liberty.<br /> [Benjamin Franklin]<br /> <br /> -- <br /> PHP General Mailing List (http://www.php.net/)<br /> To unsubscribe, visit: http://www.php.net/unsub.php</p> </article> <article> <h2>RE: Textarea to road a text file</h2><span>am 29.10.2009 13:14:26 von Jay Blanchard</span> <p>[snip]<br /> <html><head><title>.....<br /> <body>..............<br /> <br /> <?php<br /> <br /> $handle =3D fopen("./menu.php", "r");<br /> $contents =3D "";<br /> <br /> if ($handle) {<br /> while (!feof($handle)) {<br /> $buffer =3D fgets($handle);<br /> <br /> $contents =3D $contents . $buffer;<br /> }<br /> fclose($handle);<br /> }<br /> <br /> echo "<textarea cols=3D80 rows=3D30>" . $contents . "</textarea>";<br /> <br /> ?><br /> <br /> </body><br /> </html><br /> [/snip]<br /> <br /> Try http://us3.php.net/manual/en/function.file-get-contents.php<br /> <br /> <?php<br /> <br /> $contents =3D file_get_contents('./menu.php');<br /> <br /> echo "<textarea cols=3D80 rows=3D30>" . $contents . "</textarea>";<br /> <br /> ?><br /> <br /> I am unsure what you want to do here, display the menu in the textarea?<br /> Or do you want to be able to edit menu.php in the textarea?<br /> <br /> -- <br /> PHP General Mailing List (http://www.php.net/)<br /> To unsubscribe, visit: http://www.php.net/unsub.php</p> </article> <article> <h2>Re: Textarea to road a text file</h2><span>am 31.10.2009 07:14:52 von Jean Lee</span> <p>Yes, I just want to edit a file in the textarea!<br /> thank you.<br /> <br /> ""Jay Blanchard"" <jblanchard@pocket.com> wrote in message <br /> news:31454D514FF9A949B1FDFE294D5D1D8008017D@ygex01wal.onecal l.local...<br /> [snip]<br /> <html><head><title>.....<br /> <body>..............<br /> <br /> <?php<br /> <br /> $handle = fopen("./menu.php", "r");<br /> $contents = "";<br /> <br /> if ($handle) {<br /> while (!feof($handle)) {<br /> $buffer = fgets($handle);<br /> <br /> $contents = $contents . $buffer;<br /> }<br /> fclose($handle);<br /> }<br /> <br /> echo "<textarea cols=80 rows=30>" . $contents . "</textarea>";<br /> <br /> ?><br /> <br /> </body><br /> </html><br /> [/snip]<br /> <br /> Try http://us3.php.net/manual/en/function.file-get-contents.php<br /> <br /> <?php<br /> <br /> $contents = file_get_contents('./menu.php');<br /> <br /> echo "<textarea cols=80 rows=30>" . $contents . "</textarea>";<br /> <br /> ?><br /> <br /> I am unsure what you want to do here, display the menu in the textarea?<br /> Or do you want to be able to edit menu.php in the textarea? <br /> <br /> <br /> <br /> -- <br /> PHP General Mailing List (http://www.php.net/)<br /> To unsubscribe, visit: http://www.php.net/unsub.php</p> </article> <footer> <a href="/">Index</a> | <a href="/impressum.php">Impressum</a> | <a href="/datenschutz.php">Datenschutz</a> | <a href="https://www.xodox.de/">XODOX</a> </footer> </main> </body> </html>