MyBB Community Forums

Full Version: Coding Problem
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi, I created a php script so I can remotly edit files on my server, the problem I have is that if the file I want to edit has a </textarea> the php script breaks before this and echo's the rest of the file outside of the textarea on the php script so I can't finish editing the file I want to edit.

I spent almost 3 hours today trying to fix this and failed Sad.

Please help, many thanks in advance Smile.

Screenshot of problem:
[Image: 97196959.png]

<?php
$myFile = "testFile.php";
$fh = fopen($myFile, 'r');
$theData = fread($fh, filesize($myFile));
fclose($fh);
?>

<form action="ef.php" method="post">
<textarea name="data" cols="40" rows="5">
<?php echo $theData; ?>
</textarea><br>
<input type="submit" value="Submit" />
</form>

testFile.php
<textarea>
lalala
</textarea>
testing
You have a textarea in your textarea?? That doesn't work. The first </textarea> will end up closing your textarea.
(2009-04-29, 12:46 PM)hamster Wrote: [ -> ]You have a textarea in your textarea?? That doesn't work. The first </textarea> will end up closing your textarea.

The first textarea is in another file testFile.php, I would have thought the textarea on the php script would ignore the textarea in the testFile.php Huh
It does not work like that. PHP doesn't just ignore something that is in a string. You have to define something that strips it out.
And for HTML, you can't nest things that is not meant to be nested, and no a browser should not ignore it.
<?php echo htmlentities($theData); ?>
(2009-04-29, 09:23 PM)resig Wrote: [ -> ]
<?php echo htmlentities($theData); ?>

Works Perfect, Thank You! Big Grin