使用PHP重定向到上一页的最简单方法是什么? [英] What's the easiest way to redirect to the previous page with PHP?

查看:80
本文介绍了使用PHP重定向到上一页的最简单方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用表单将一些帖子信息提交给PHP脚本。脚本完成后,我希望它重定向到用户来自的页面。现在我只使用header()和一个静态URL。我在互联网上发现了很多关于这个问题的非常矛盾的信息,所以我想知道StackOverflow是怎么想的。

使用 HTTP_REFERER

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


I'm using a form to submit some post information to a PHP script. After the script finishes, I want it to redirect right back to the page the user came from. Right now I'm just using header() with a static URL. I've found a ton of very conflicting information about this around the internet, so I'm wondering what StackOverflow thinks.

解决方案

Use HTTP_REFERER:

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

这篇关于使用PHP重定向到上一页的最简单方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆