duanbu4962 2012-03-23 22:03
浏览 16
已采纳

引用一个调用特定页面的页面

I have an index page with three links as follws. When I click the first link (pageType1 in the example below), pageType1.php is run that first check if the user is logged in via cookie. If it is not then redirect the user to a login page. when a user submit login and password info on login page correctly, I want to display the info on pageType1.php

FILE: index.php

<a href="pageType1.php" target="_blank">PageType1</a>
<a href="pageType2.php" target="_blank">PageType2</a>
<a href="pageType3.php" target="_blank">PageType3</a>

FILE : pageType1.php

<?php
include"auth/auth_check_header.php"; 
print("pageType1 contents");
?>

FILE : pageType2.php

<?php
include"auth/auth_check_header.php"; 
print("pageType2 contents");
?>

FILE : pageType3.php

<?php
include"auth/auth_check_header.php"; 
print("pageType3 contents");
?>

FILE : auth/auth_check_header.php

$successful_login_url = ??????   //How to track this value. 

if (!cookie_enabled)
    {
    //login page
    header("location:$successful_login_url");
    }

My question is how to track "$successful_login_url" value (Or what shoud I put as the value of this variable) in auth/auth_check_header.php

Note: I tried putting $_SESSION["referer"] as the value of "$successful_login_url" but it shows index.php after successful login. Thanks in advance

  • 写回答

2条回答 默认 最新

  • douw92892 2012-03-23 22:20
    关注

    1) User try to access a pageType1.php

    2) The user is redirected to the login.php which contains a form with the hidden field:

    <input type="hidden" name="redirectTo" value="<?php echo $_SESSION["HTTP_REFERER"]?>" />
    

    3) User type the login and when successfully authenticated:

    $redirectTo = $_POST['redirectTo']

    4) If $redirectTo is not empty, then redirect, else redirect to a default page

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥35 平滑拟合曲线该如何生成
  • ¥100 c语言,请帮蒟蒻写一个题的范例作参考
  • ¥15 名为“Product”的列已属于此 DataTable
  • ¥15 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 自己瞎改改,结果现在又运行不了了
  • ¥15 链式存储应该如何解决
  • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站