Textarea to road a text file

View: New views
7 Messages — Rating Filter:   Alert me  

Textarea to road a text file

by Jean Lee-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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

by Jay Blanchard-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

[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?

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


Re: Textarea to road a text file

by Andrew Ballard :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Wed, Oct 28, 2009 at 10:39 AM, Jean Lee <versus100@...> 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.

<textarea name="mytextarea"><?php echo
htmlspecialchars($text_content); ?></textarea>

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

by Jean Lee-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thank you, Jay Blanchard and Andrew Ballard!!!

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


<html><head><title>.....
<body>..............

<?php

$handle = fopen("./menu.php", "r");
$contents = "";

if ($handle) {
    while (!feof($handle)) {
        $buffer = fgets($handle);

        $contents = $contents . $buffer;
    }
    fclose($handle);
}

echo "<textarea cols=80 rows=30>" . $contents . "</textarea>";

?>

</body>
</html>



""Jay Blanchard"" <jblanchard@...> wrote in message
news:31454D514FF9A949B1FDFE294D5D1D80080142@......
[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?



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


Re: Textarea to road a text file

by Bugzilla from spam@network-technologies.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Jean Lee wrote:

> Could you explain what was my fault concerned about this case?
> <?php
>
> $handle = fopen("./menu.php", "r");
> $contents = "";
>
> if ($handle) {
>     while (!feof($handle)) {
>         $buffer = fgets($handle);
>
>         $contents = $contents . $buffer;
>     }
>     fclose($handle);
> }
>
> echo "<textarea cols=80 rows=30>" . $contents . "</textarea>";
> ?>

As Andrew pointed out, you need to use htmlspecialchars()
        echo "<textarea cols=80 rows=30>" .htmlspecialchars($contents).
"</textarea>";

The reason for that is because the text may contain html control
characters like <>&'" which the browser will attempt to interpret.

http://php.net/htmlspecialchars

I usually use htmlentities() instead
http://de.php.net/manual/en/function.htmlentities.php

--
John
Those willing to give up a little liberty for a little security
deserve neither security nor liberty.
[Benjamin Franklin]

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


RE: Textarea to road a text file

by Jay Blanchard-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

[snip]
<html><head><title>.....
<body>..............

<?php

$handle = fopen("./menu.php", "r");
$contents = "";

if ($handle) {
    while (!feof($handle)) {
        $buffer = fgets($handle);

        $contents = $contents . $buffer;
    }
    fclose($handle);
}

echo "<textarea cols=80 rows=30>" . $contents . "</textarea>";

?>

</body>
</html>
[/snip]

Try http://us3.php.net/manual/en/function.file-get-contents.php

<?php

$contents = file_get_contents('./menu.php');

echo "<textarea cols=80 rows=30>" . $contents . "</textarea>";

?>

I am unsure what you want to do here, display the menu in the textarea?
Or do you want to be able to edit menu.php in the 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

by Jean Lee-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Yes, I just want to edit a file in the textarea!
thank you.

""Jay Blanchard"" <jblanchard@...> wrote in message
news:31454D514FF9A949B1FDFE294D5D1D8008017D@......
[snip]
<html><head><title>.....
<body>..............

<?php

$handle = fopen("./menu.php", "r");
$contents = "";

if ($handle) {
    while (!feof($handle)) {
        $buffer = fgets($handle);

        $contents = $contents . $buffer;
    }
    fclose($handle);
}

echo "<textarea cols=80 rows=30>" . $contents . "</textarea>";

?>

</body>
</html>
[/snip]

Try http://us3.php.net/manual/en/function.file-get-contents.php

<?php

$contents = file_get_contents('./menu.php');

echo "<textarea cols=80 rows=30>" . $contents . "</textarea>";

?>

I am unsure what you want to do here, display the menu in the textarea?
Or do you want to be able to edit menu.php in the textarea?



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