我使用了一个代码作为头文件:
$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变量来获取它所在的页面的完整url,当我单击submit时,我希望它重定向到标题所在的页面。。我将url添加到表单的操作中..
但我得到的是:
Undefined index: PATH_INFO我试着用这些来代替:
explode('/', substr(parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH),1));
$_ENV['PATH_INFO'];但是它们也不起作用:
发布于 2011-10-19 15:44:59
<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>发布于 2012-11-10 13:15:34
您还可以尝试:
<form action="<?=$_SERVER['PHP_SELF']?>" method="POST">
<input type="submit" name="form-submit" value="Submit" />这将导致表单在自身(当前页面)上提交。在表单中使用变量来检测提交或“常规页面加载”。例如。
if (isset($_POST['form-submit'])){
//do stuff
}发布于 2019-08-12 00:49:34
在较新的环境中,对于Apache / PHP-FPM,您需要在php.ini中启用以下选项,以避免"Undefined index: PATH_INFO“
cgi.fix_pathinfo=1https://stackoverflow.com/questions/7818038
复制相似问题