$_SERVER['PATH_INFO'] ..未定义索引:PATH_INFO

发布于 2024-12-10 11:00:02 字数 1218 浏览 1 评论 0原文

我正在使用一个代码作为标题:

$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 技术交流群。

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

发布评论

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

评论(3

a√萤火虫的光℡ 2024-12-17 11:00:02
  <form action="" method="POST">

仅此而已

,回显原始 HTML 是没有意义的
使用此代码代替您的代码

?>
  <form action="" 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>

  <form action="" method="POST">

that's all

also, there is no point in echoing raw HTML
use this code instead of yours

?>
  <form action="" 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>

三生路 2024-12-17 11:00:02

您还可以尝试:

<form action="<?=$_SERVER['PHP_SELF']?>" method="POST">
<input type="submit" name="form-submit" value="Submit" />

这将导致表单自行提交(当前页面)。在表单中使用变量来检测提交或“常规页面加载”。例如

if (isset($_POST['form-submit'])){
    //do stuff
}

You can also try:

<form action="<?=$_SERVER['PHP_SELF']?>" method="POST">
<input type="submit" name="form-submit" value="Submit" />

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.

if (isset($_POST['form-submit'])){
    //do stuff
}
谁的新欢旧爱 2024-12-17 11:00:02

在较新的环境中,使用 Apache / PHP-FPM,您需要在 php.ini 中启用以下选项,以避免“未定义索引:PATH_INFO >”

cgi.fix_pathinfo=1

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"

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