Jump to content

Preventing <textarea> from being broke when it contains another <textarea>


sw0o0sh

Recommended Posts

Hi, I've nearly perfected my content management system (basically my own geocities yay) after many stressful encounters with functions and needing about 1000 brain blasts to code what I was able to at times.

But anyway, now I'm at a little bit less difficult run in, yet stumped too. The part of my site where you edit the file is pretty much flawless, except for one thing, when you request that your file is to be editted, and the file to be editted contains a <textarea>, the <textarea> you edit in breaks. I tried variations of htmlspecialchars() and such in random areas, but that isnt going to work; and hasn't.

So here's my code as of now, (ignore the invalid structure, im just pasting a piece of a huge file)

[code]
else if($_GET[act] == 'edit'){
if($_POST[alter])
{
$opennew=fopen("directory/".$logged[webpage]."/".$_GET[edit],'w');
$content=stripslashes($_POST[content]);
fwrite($opennew,$content);
}
$open=fopen("directory/".$logged[webpage]."/".$_GET[edit],'r');
?>
<form style='text-align:center;' method='post' action='manage.php?act=edit&edit=<?PHP echo $_GET[edit]; ?>'>
<textarea style='font-family:times new roman;font-size:12pt;' rows='20' cols='100' width='100%' name='content'>
<?PHP
while(!feof($open))
{
echo fgets($open);
}
?>
</textarea><br />
<input type='submit' name='alter' value='Update Page' />
<input type='reset' value='Undo Changes' />
<input type='button' value='Preview Page' onclick='window.location="directory/<?PHP echo $logged[webpage]."/".$_GET[edit]; ?>";' />
</form>
[/code]

I obviously know what I have now isn't an attempt at fixing the error, i just left it normal as i gave up trying along time ago as this simple feature to the site was one of the first things I did and decided to get to last.

Thanks anybody.
Link to comment
Share on other sites

[quote author=Jocka link=topic=116764.msg475923#msg475923 date=1164837357]
lmao I didn't even mean to answer with that. I thought you already used it when you said "I tried variations of htmlspecialchars() and such in random areas..."
[/quote]

No, i was trying stupid stuff like htmlspecialchars(include()) and such. And when i tried altering fgets i put the function after fgets not before. So thanks again
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.