php / html - http_referer [英] php/html - http_referer

查看:97
本文介绍了php / html - http_referer的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个网站,并在一个特定的页面上,想要将用户发回到上一页。我对PHP / HTML相当陌生,并且已经使用一些现有的代码来提供想法和帮助。

现有代码使用以下方法:

  if(!empty($ HTTP_REFERER))
{
header(Location:$ HTTP_REFERER);
} else
{
header(Location:$ CFG-> wwwroot);
}

但是,当我使用这段代码时,HTTP_referer总是被视为空,用户重定向到根页面。

解决方案

您需要使用:

  $ _ SERVER ['HTTP_REFERER'] 


I am creating a website and on one particular page, am wanting to send the user back to the previous page. I am fairly new to PHP/HTML and have been using some existing code for ideas and help.

The existing code uses the following method:

if (! empty($HTTP_REFERER)) 
{
    header("Location: $HTTP_REFERER");
} else 
{
    header("Location: $CFG->wwwroot");
}

However, when I use this code the HTTP_referer is always treated as empty and the user redirected to the root page. Any obvious flaws in this code?

解决方案

You need to use:

$_SERVER['HTTP_REFERER']

这篇关于php / html - http_referer的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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