简体   繁体   English

如何不允许用户提交链接? (html表格/ PHP / javascript)

[英]How to not allow user to submit links? (html form/PHP/javascript)

I have an idea for a website and I will be using a form to allow users to submit a text. 我有一个网站的想法,我将使用一个表格来允许用户提交文本。 The problem is that I don't want anyone to register(because I think that my idea is much more fun without registering as more people will use it) and by doing that I'm sure that people will spam the sh** out of my website. 问题是我不想让任何人注册(因为我认为我的想法如果不进行注册就会变得更加有趣,因为更多的人会使用它),并且这样做,我确定人们会向垃圾邮件发送垃圾邮件我的网站。

My question is: What's the easiest way to prevent this from happening? 我的问题是:防止这种情况发生的最简单方法是什么? It must be a really good way to block html code and any other pattern/tricks(spaces has to be filtered) spammers will use to submit links.. Of course I will use CAPTCHA to stop automated submission, my concern is about people manually submitting links. 这肯定是阻止html代码的真正好方法,垃圾邮件发送者将使用其他任何模式/技巧(必须过滤空格)来提交链接。.当然,我将使用CAPTCHA来停止自动提交,我担心的是人们手动提交链接。

Thanks in advance. 提前致谢。

strip_tags should work for most cases. strip_tags应该适用于大多数情况。 I personally favor using a more comprehensive library to handle user-submitted text. 我个人更喜欢使用更全面的库来处理用户提交的文本。 htmLawed is excellent for this purpose. htmLawed非常适合此目的。

http://www.bioinformatics.org/phplabware/internal_utilities/htmLawed/index.php http://www.bioinformatics.org/phplabware/internal_utilities/htmLawed/index.php

You could also moderate submissions or use a spam filtering service. 您也可以审核提交内容或使用垃圾邮件过滤服务。 There quite are a few services out there that have APIs: 有很多具有API的服务:

http://akismet.com/ http://akismet.com/

http://mollom.com http://mollom.com

http://antispam.typepad.com http://antispam.typepad.com

using simple validation in complex ways can help you do whatever you want. 以复杂的方式使用简单的验证可以帮助您做任何想做的事情。 Just pass the input through a function to do whatever you want. 只需通过函数传递输入即可执行任何所需的操作。

function validate(i)
{
  var i = document.getElementById(i).value;
  if($i contins foo)
    {
      disable submit button
    }
}

<input type="text" id='url' onblur="validate(this.id)">
    <input type="submit" >

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM