如何不允许用户提交链接? (html 表单/PHP/javascript)
我有一个网站的想法,我将使用一个表单来允许用户提交文本。问题是我不想让任何人注册(因为我认为我的想法在不注册的情况下会更有趣,因为更多的人会使用它)并且通过这样做,我确信人们会发送垃圾邮件我的网站。
我的问题是:防止这种情况发生的最简单方法是什么?这一定是阻止 html 代码和任何其他模式/技巧(必须过滤空格)垃圾邮件发送者用来提交链接的好方法。当然我会使用验证码来停止自动提交,我担心的是人们手动提交链接。
提前致谢。
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.
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
strip_tags
应该适用于大多数情况。我个人倾向于使用更全面的库来处理用户提交的文本。 htmLawed 非常适合此目的。http://www.bioinformatics.org/phplabware/internal_utilities/htmLawed/index.php
strip_tags
should work for most cases. I personally favor using a more comprehensive library to handle user-submitted text. htmLawed is excellent for this purpose.http://www.bioinformatics.org/phplabware/internal_utilities/htmLawed/index.php
您还可以审核提交内容或使用垃圾邮件过滤服务。有相当多的服务具有 API:
http://akismet.com/
http://mollom.com
http://antispam .typepad.com
You could also moderate submissions or use a spam filtering service. There quite are a few services out there that have APIs:
http://akismet.com/
http://mollom.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.