繁体   English   中英

自我提交表格,然后刷新页面?

[英]Self submitting form, then refresh page?

我在PHP中有一个页面,其中的表单包含多个复选标记。 这些选中标记可用于删除记录或为选定的内容创建标签。

我使用同一页面($ _SERVER ['PHP_SELF'])来运行查询时,删除部分运行得很好,但是标签不起作用,因为我需要将值传递给另一个名为PDF_Label_Print.php的页面。 如果可能的话,我想远离会话变量。

该页面有效,但有时不会自动刷新。 有任何想法吗? 谢谢!

if (isset($_GET['labels']) && (is_array($news_ids) && count($news_ids) > 0))
{
    $label_list  = implode(',', $news_ids);
    echo "<form action='PDF_Label_Print.php' method='post' name='frm' target='_blank'>
    <input type='hidden' name='full_list' value='". htmlentities(serialize($label_list)) ."' />
    <input type='hidden' name='tbl_name' value='" . $_SESSION['officeid'] ."' />
    <input type='hidden' name='report' value='list' />
    <input type='hidden' name='avery' value='5160' />
    </form>";

    echo "<script language='JavaScript'>document.frm.submit();</script>";
    // refresh page.

    echo '<script language="javascript">window.location = "welcome.php"</script>';
}

问题是提交表单后,javascript可能会停止工作,直到发布完成,并且表单操作是另一个页面。但是,再次提交表单(不带ajax)时,页面应自动刷新。

因此,您需要在PDF_Label_Print.php页面上将其重定向回到欢迎页面。

header("location:welcome.php"); // or anyother page you want to redirect after posting

感谢您抽出宝贵时间来研究我的问题。

原来,我能够通过在表单上使用POST而不是GET来解决此问题。 页眉位置现在可以正确刷新页面。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM