是否应该将 AJAX 调用的处理/验证数据的 PHP 文件放在“include”中?文件夹并使用户无法访问?

发布于 2024-09-01 09:06:35 字数 239 浏览 4 评论 0原文

我的问题是假设我有一个需要通过 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

恏ㄋ傷疤忘ㄋ疼 2024-09-08 09:06:35

您无法阻止用户直接访问该文件。如果这样做,您也会阻止 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文