是否应该将 AJAX 调用的处理/验证数据的 PHP 文件放在“include”中?文件夹并使用户无法访问?
我的问题是假设我有一个需要通过 AJAX 进行验证的表单。 AJAX 将数据发送到名为 do_ajax_validation.php
的文件。现在我应该将此文件放在“include”文件夹中并将其命名为 do_ajax_validation.inc.php
并禁止用户直接访问它还是应该将其放在原始表单所在的目录中?
编辑:同样的问题是对于处理表单数据的文件(或在表单标记的操作属性中定义的文件)
My Question is suppose I have a form which needs validation through AJAX. The AJAX is sending data to to a file called do_ajax_validation.php
. Now should I put this file in 'include' folder and name it do_ajax_validation.inc.php
and bar it from direct access of the user or should I put it in the directory in which the original form resides?
Edit: And the same question is for the files which do processing of data of forms (or the files which are defined in the action property of the form tag)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您无法阻止用户直接访问该文件。如果这样做,您也会阻止 XMLHttpRequest 对象访问它!
您应该有一个合理的 URI 供 XHR 访问。除此之外,以任何使站点最容易维护的方式构建文件。
You can't prevent the user from directly accessing the file. If you do, you prevent the XMLHttpRequest object from accessing it too!
You should have a reasonable URI for the XHR to access. Beyond that, structure your files in whatever fashion makes the site easiest to maintain.