使用HTML表单操作与另一个目录中的PHP脚本是(相对路径) [英] Using HTML form action with a php script being in another directory (relative paths)
问题描述
下面就是我的diretory树看起来像
Here's what my diretory tree looks like
/application
/lib
/util
/login
/views
/base_view
我的登录页面
localhost:737/astuto-lena/branches/application/views/base_view/index.php
和我希望我的表单的动作是这样的。
And I want the action of my form to be this
localhost:737/astuto-lena/branches/application/util/login/main.php
下面是我的形式声明
<form class="form_login" action="./util/login/main.php" method="POST">
...
</form>
但是,当我点击提交按钮,它带我到
But when I click the submit button, it takes me to
localhost:737/astuto-lena/branches/application/views/base_view/util/login/main.php
这是错误的道路,并生成一个错误404。
Which is the wrong path and generates a Error 404.
那么,什么是错,我用我的窗体声明相对路径的方式,我该如何解决呢?
So what's wrong with the way I'm using relative paths in my form declaration and how can I fix that?
推荐答案
在您的相对路径 ./ UTIL /登录/ main.php
,你使用 ./
指到当前文件夹,因此它假定文件夹结构 / UTIL /登录
里面 / base_view
。你应该尝试使用 ../
这是指父文件夹:
In your relative path ./util/login/main.php
, you're using ./
which refers to the current folder, so it assumes that the folder structure /util/login
is inside /base_view
. You should try using ../
which refers to the parent folder:
<form class="form_login" action="../../util/login/main.php" method="POST">
...
</form>
这篇关于使用HTML表单操作与另一个目录中的PHP脚本是(相对路径)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!