$_SERVER['PATH_INFO'] ..未定义索引:PATH_INFO
我正在使用一个代码作为标题:
$fullurl=$_SERVER['PATH_INFO'];
echo '
<form action="'. $fullurl .'" method="POST">
<table width="1000" border="1" cellpadding="10" id="navigationBar">
<tr>
<td> <a href="/PoliticalForum/Registration.php">Register</a></td>
<td> <a href="/PoliticalForum/controlPanel.php">Control Panel</a></td>
<td> <a href="/PoliticalForum/checkEmail.php">Donate</a> </td>
<td align="right">name:<input name="name" type="text" /></td>
<td>password:<input name="pass" type="text" /> <input name="login" type="submit" value="Login" /> </td>
</tr>
</table>
</form>
';
我使用 require 一次将标题包含在页面文件中。我想要的是 fullurl 变量来获取“required_once”所在页面的完整 url,当我单击提交时,我希望它重定向到标题所在的页面。我将 url 添加到了操作中 我
但我得到的是这样的:
Undefined index: PATH_INFO
尝试用它们来代替:
explode('/', substr(parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH),1));
$_ENV['PATH_INFO'];
但它们也不起作用:(
I am using a code to be put as a header:
$fullurl=$_SERVER['PATH_INFO'];
echo '
<form action="'. $fullurl .'" method="POST">
<table width="1000" border="1" cellpadding="10" id="navigationBar">
<tr>
<td> <a href="/PoliticalForum/Registration.php">Register</a></td>
<td> <a href="/PoliticalForum/controlPanel.php">Control Panel</a></td>
<td> <a href="/PoliticalForum/checkEmail.php">Donate</a> </td>
<td align="right">name:<input name="name" type="text" /></td>
<td>password:<input name="pass" type="text" /> <input name="login" type="submit" value="Login" /> </td>
</tr>
</table>
</form>
';
I include the header across page files with the require once. What I want is that the fullurl variable to obtain the full url of the page it is "required_once" on, and when I click submit, I want it to redirect to the page the header is on.. I added the url onto the action of the form..
But what I get is this:
Undefined index: PATH_INFO
I tried to use those instead:
explode('/', substr(parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH),1));
$_ENV['PATH_INFO'];
But they didnt work too :(
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
仅此而已
,回显原始 HTML 是没有意义的
使用此代码代替您的代码
that's all
also, there is no point in echoing raw HTML
use this code instead of yours
您还可以尝试:
这将导致表单自行提交(当前页面)。在表单中使用变量来检测提交或“常规页面加载”。例如
You can also try:
This will cause the form to submit on itself (current page). Use a variable in your form to detect submission or 'regular page load'. E.g.
在较新的环境中,使用 Apache / PHP-FPM,您需要在 php.ini 中启用以下选项,以避免“未定义索引:PATH_INFO >”
In a more recent environment, with Apache / PHP-FPM you need to enable the following option in php.ini to avoid "Undefined index: PATH_INFO"