在我的html中,我现在有:
<input type="hidden" name="redirect" value="example.com" />是否可以将值更改为重定向到当前页面(基本上是刷新页面),而不必手动为每个页面插入url?
发布于 2017-10-09 11:19:27
是的,您可以将此函数添加到代码中。我在我的一些应用程序中使用它
创建如下功能:
function getPageUrlNoQuery()
{
$pageUrl = ($_SERVER['PHP_SELF']);
return $pageUrl;
}包括函数文件,并调用。
<input type="hidden" name="redirect" value="<?php echo getPageUrlNoQuery() ?>" />已经编辑过了,我认为只要您可以调用函数或类,大多数体系结构都应该这样做。不管你用哪种。
发布于 2017-10-09 11:19:44
嗯,在PHP中,您应该知道您正在加载哪个页面,然后将该值放入其中。(我不知道您的体系结构,但是要么手动在控制器中设置变量,要么不使用控制器,然后是simply extract the URL from the get request.)
或者,您可以使用Javascript:
document.getElementById('YourLink').value = window.location.href;https://stackoverflow.com/questions/46645032
复制相似问题