English 中文(简体)
转向页面用户正试图在伐木后进入
原标题:Redirect to page user was trying to get to after logging in
  • 时间:2011-08-10 00:10:01
  •  标签:
  • php
  • redirect

阅读一个比照,以找到答案,不要太高。

我有一个网站,成员可以匿名浏览该网站,但有些网页受到限制。 我的成员们在点击需要他们看上去的链接后,立即转往一个标识页。

我不知道如何把该成员转移到他们试图一度gged忙的网页上。

他们试图听从/听说。 页: 1 phtml, 如今,当它们投了出来时,我希望将其送交/注解。 页: 1 如果他们点击/album.phtml,我想在登录后将其送往album.phtml。

谁能帮助? 我是否在一届会议上储存了URL?

非常感谢。

最佳回答

早在发布<代码>标题(“Location:”)前,即要求改头,将其目前改载于的网页上,_SESSION[ redirect_to]。 成功登录后,再打电话header (>) ,转回原来的网页,不打乱届会的变数,以免意外地重复任何地方。

$_SESSION[ redirect_to ] = $_SERVER[ REQUEST_URI ];
header("Location: http://example.com/login.php");
exit();

// On successful login
$redirect = $_SESSION[ redirect_to ];
// unset the session var
unset($_SESSION[ redirect_to ]);
header("Location: http://example.com/$redirect");
exit();
问题回答

你可以很好地利用像其他人所建议的那样的届会变量。 然而,我只依靠吉大港山区。 这里的缺点并非每一个浏览器都发送了一名参考资料,而是大多数主要浏览器。 它属于吉大港山区标准的一部分,我认为它非常好。 在您的文字中说明这一点。

if(!empty($_SERVER[ HTTP_REFERER ])) { header( Location:  .$_SERVER[ HTTP_REFERER ]); }




相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签