PHP 操作表单无效。即使文件存在,操作表单的根目录也会显示 404

PHP action form is not working. root of the action form shows 404 even when the file is there

当相同的 .PHP 文件(带有表单和操作的文件)位于 some 文件夹中时,它工作得很好。但出于安全原因,我需要文件夹外的 'action' 文件具有另一个路径。

我正在正确编写代码(我猜):

action="../connect/dashboard/admin/register_dw_user.php"

    

这对我来说没有意义,很明显我错过了什么。但是我不知道是什么。

connect.php 文件到 link MYSQL 数据库工作正常,它也在同一个 'connect' 文件夹中。我正在使用:

       include '../connect/lib/connect.php';

清楚地表明 'connect' 文件夹仅在 'public' 文件夹之上。但由于某种原因无法使用操作表单。

这是我尝试过但没有奏效的方法:

 action="/connect/dashboard/admin/register_dw_user.php"
 action="../connect/dashboard/admin/register_dw_user.php"
 action="../../connect/dashboard/admin/register_dw_user.php"
 action="../../../connect/dashboard/admin/register_dw_user.php"
 action="connect/dashboard/admin/register_dw_user.php"

有什么想法吗?请!我需要帮助!

您应该始终使用绝对路径,尤其是当您从不同文件夹访问文件时

离线使用 这是如果您甚至不尝试渲染 php,只是测试提交按钮是否调用正确的文件

For example say your form.htm is located at [Drive]/myname/admin/data/form.htm
and your processor.php is at [SameDrive]/myname/admin/data/anotherdata/processor.php

to call that php file from htm you set your action to action="/myname/admin/data/anotherdata/processor.php"

对于本地主机或服务器[如果你在服务器上] 通常路径是“www/”或“www/root/”

say your form.htm is located at www/root/admin/data/form.htm
and your processor.php is at www/root/admin/data/anotherdata/processor.php

you can now use action="/admin/data/anotherdata/processor.php"

或者

您可以在路径前添加 url,例如:

action="https://myurl.com/admin/data/anotherdata/processor.php"