dousongqiang2585 2016-10-17 03:35
浏览 24
已采纳

如何在使用带有值的按钮重定向到另一页时删除确认表单重新提交

Good day, as the title says, how can I do that? What I'm trying to do is that on page 1, I looped all data with each having a button that has value of their specific id, then that button redirects to a common page 2, then I use that id on page 2 to display their whole data, but the problem is that when I refresh, the dialog appears.

I tried using session, but the problem is that when multiple tabs are accessing it.

I haven't really tried PRG, but on my understanding, it is used to send changes to the server using another page, then redirect to the previous page, preventing the dialog when refreshing. I thought of using it, but I don't know how to send the fetched data from page 1.5 to page 2

I'd be really grateful for a solution to this, or if someone can link me to similar problems. Maybe this is a duplicate question, but I just can't find the term for my problem. Cheers!!

  • 写回答

1条回答 默认 最新

  • donglingyi4679 2016-10-17 08:35
    关注

    If you control both pages, change the redirect mechanism on page 1 to GET by simply redirecting to a URL with a parameter appended to the address: target.php?id=42.

    If you control only page 2, you may convert a POST request with an id to a GET request:

    if (isset($_POST['id']))
    {
        header('Location: target.php?id=' . $_POST['id']);
        exit;
    }
    

    More on GET vs POST here, as well as a couple of other answers.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 使用C#,asp.net读取Excel文件并保存到Oracle数据库
  • ¥15 C# datagridview 单元格显示进度及值
  • ¥15 thinkphp6配合social login单点登录问题
  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 虚心请教几个问题,小生先有礼了
  • ¥30 截图中的mathematics程序转换成matlab