建立安全的联系表格
我正在构建一个联系表单
(PHP文件,设计已经完成),它将通过AJAX
与PHP进行通信。我需要保护联系表单的安全以拒绝任何垃圾邮件,对于客户端,我将使用 ReCaptcha
用于客户端验证...但是,如何保护脚本不被篡改或发送任意代码?
我的意思是,如果垃圾邮件发送者/黑客使用该表单并提交可能影响服务器的 PHP 代码,我该如何防止这种情况发生?
I'm building a contact form
(PHP file, design has been already made) which will communicate with the PHP via AJAX
. I need to secure the contact form to deny any spam, for the client side, I'll be using ReCaptcha
for the validation on client side ... But, how can I secure the script from being tampered with or sending arbitrary codes?
I mean, if the spammer/hacker uses the form and submits a PHP code that could affect the server, how can I prevent this from happening?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在联系表单中输入的文本不应被执行,而只能通过电子邮件传递。因此,无论黑客提交什么内容,最糟糕的情况就是出现在表单后面的邮箱中。
在联系表单发送的内容上使用
htmlentities
始终是一个好主意,因此如果使用任何 HTML 字符,它们不会造成任何损害。The text that has been entered in your contact form should never be executed, only passed along in an e-mail message. So, whatever a hacker would submit, the worst it should be able to do is show up in the mailbox behind the form.
It's also always a good idea to use
htmlentities
on the content sent from your contact form, so if any HTML characters are used, they can't do any harm.阅读
使用 php 验证表单
have a read
Validate form with php