douwang4374 2016-04-03 05:58
浏览 33

添加记录PHP后返回上一页

I have 2 PHP pages. One in the "add.php" page and the other is the "proccess.php" page. The "process.php" is simply the php the saves the added record to mysql database.

After the record is saved, I have the following to go to specific page after record is saved.

header('Refresh: 3; URL=edit/edit.php'); 

Rather then do this, I would like it to go back to the previous page "add.php". But I don't want to specify the page, just tell it to go back 1 page.

  • 写回答

1条回答 默认 最新

  • dongqu1783 2016-04-03 06:02
    关注

    Try this:

     header('Location: ' . $_SERVER['HTTP_REFERER']);
    

    Note that this may not work with secure pages (HTTPS) and it's a pretty bad idea overall as the header can be hijacked.


    Or this one:

    header("location:javascript://history.go(-1)");
    

    Hope this helps.

    评论

报告相同问题?

悬赏问题

  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效
  • ¥15 悬赏!微信开发者工具报错,求帮改
  • ¥20 wireshark抓不到vlan
  • ¥20 关于#stm32#的问题:需要指导自动酸碱滴定仪的原理图程序代码及仿真
  • ¥20 设计一款异域新娘的视频相亲软件需要哪些技术支持