dongxian7489 2011-05-17 11:52
浏览 13

成功完成任务后,在上一页重定向用户

What should be good way to redirect user after successful action like edit or delete any item, in delete condition we could use $_SERVER['HTTP_REFERER'] but in case of edit, we show first of all edit form and then user clicks update, so if we use same approach user would be redirected to edit page not main page. I hope you got idea about my confusion. thanks.

  • 写回答

5条回答 默认 最新

  • dongxun2089 2011-05-17 11:56
    关注

    If 'update' is handled through a Form post, just put a hidden input in reflecting the landing spot.

    <input type="hidden" name="next_url" value="foo.php" />
    

    The PHP uses the value as the place to redirect to.

    <?php
      // Do operations.
      header('Location: '.$_REQUEST['next_url']);
    

    This is especially important because HTTP_REFERER is not guaranteed to work. It works most of the time, but there are issues with relying on it.

    评论

报告相同问题?

悬赏问题

  • ¥15 livecharts wpf piechart 属性
  • ¥20 数学建模,尽量用matlab回答,论文格式
  • ¥15 昨天挂载了一下u盘,然后拔了
  • ¥30 win from 窗口最大最小化,控件放大缩小,闪烁问题
  • ¥20 易康econgnition精度验证
  • ¥15 msix packaging tool打包问题
  • ¥28 微信小程序开发页面布局没问题,真机调试的时候页面布局就乱了
  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置