dty5753 2011-10-08 17:41
浏览 426
已采纳

如何保持HTML标记<p>&</ p>不转换为&lt; p&gt; 和&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>
  • 写回答

1条回答 默认 最新

  • dougou6213 2011-10-08 17:58
    关注

    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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 linux驱动,linux应用,多线程
  • ¥20 我要一个分身加定位两个功能的安卓app
  • ¥15 基于FOC驱动器,如何实现卡丁车下坡无阻力的遛坡的效果
  • ¥15 IAR程序莫名变量多重定义
  • ¥15 (标签-UDP|关键词-client)
  • ¥15 关于库卡officelite无法与虚拟机通讯的问题
  • ¥15 目标检测项目无法读取视频
  • ¥15 GEO datasets中基因芯片数据仅仅提供了normalized signal如何进行差异分析
  • ¥100 求采集电商背景音乐的方法
  • ¥15 数学建模竞赛求指导帮助