开发者

How to keep HTML tags <p> & </p> from converting to &lt;p&gt; and &lt;/p&gt;

I have a text box that updates/edits my database, after thousands of errors trying to get it to actually work I am now at [hopefully] the final stage!

At the moment without these edit pages, how my website is working is that I have a block of text in the database for example

[p]This is sample text[/p]

[p]This is some more sample text that will be in the next paragraph[/p]

And when it echoes out into the site the html tags disappear and the text perfectly formatted exactly how I want it to be.

However, when I add a new page or edit the existing text I end up with exactly what I wrote in the text box echoing out into the website.

What can I do to stop this happening?

Here is the code

<form id="form" name="form" method="post" action="page_edit_parse.php"  onsubmit="return validate_form ( );">

<textarea name="pagebody" id="pagebody" cols="88" rows="16"><?php echo $pagebody; ?></textarea>

<input name="pid" type="hidden" value="<?php echo $pid; ?>" />

<input type="submit开发者_运维技巧" name="button" id="button" value="Submit Page Edit" />

</form>


When the page is displayed, the content of the textarea ($pagebody) is interpreted as html, which is why the markup tags "disappear". However, when you submit the form, the textarea content is encoded, to preserve your input. The receiving script can decode the pagebody value before writing it to the database. See this related post: php htmlentities to decode textarea.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜