duancaishun4812 2012-05-10 05:03
浏览 98
已采纳

通过jQuery Ajax传递用户输入的文本,然后将结果输出给用户

I need help understanding the proper sequence of filtering data when sending user inputted comments through ajax.

My input textarea data is filtered like so

   $comment  = htmlentities(addslashes($_POST['comment']));

And I input that into the database. I need it to simply be safe text that displays symbosl. Now I need to show this content to a member with all the slashes they put in, in their comment.

I don't want to see

    The comment\'s not so pleasant to read.

I don't know how to google this question.. or formulate the sentence. I wish to be able to return a nicely formatted comment using ajax aswell. Can anyone point me in the right direction? I just wish not to be hacked :x

  • 写回答

1条回答 默认 最新

  • dongqian1028 2012-05-10 05:11
    关注

    Have you tried to strip the slashes before printing?

    echo stripslashes($str);
    

    http://php.net/manual/en/function.stripslashes.php

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

报告相同问题?

悬赏问题

  • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝
  • ¥20 腾讯企业邮箱邮件可以恢复么
  • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?
  • ¥15 错误 LNK2001 无法解析的外部符号
  • ¥50 安装pyaudiokits失败
  • ¥15 计组这些题应该咋做呀
  • ¥60 更换迈创SOL6M4AE卡的时候,驱动要重新装才能使用,怎么解决?
  • ¥15 让node服务器有自动加载文件的功能
  • ¥15 jmeter脚本回放有的是对的有的是错的
  • ¥15 r语言蛋白组学相关问题