duanlang1196 2014-03-18 20:50
浏览 47
已采纳

检查两个php页面之间的最后一次访问

Is there some sort of PHP code that allows me figure out which of the two pages was last visited.

Here is why i need it.

I have 3 pages called:

user-management.php, manage-membership.php and manage-user.php

There are two ways of getting to manage-user.php. One is to click on the name of the user in user-management.php and the other is to click on the membership account holder in membership-management. Both user-management and membership-management are completely different pages so please don't tell me to merge them to make it easier, because it won't get easier.

What i want to do is track where i'm coming from.

For example, if i'm going to manage-user.php from user-management.php, when all the editing is done, i want it to redirect back to user-management.php, and the same for membership-management.

How do i check to see which of the two pages I came from and redirect back to those pages accordingly?

  • 写回答

4条回答 默认 最新

  • drzbc6003 2014-03-18 20:56
    关注

    Have each of your scripts record their name in the $_SESSION, so you're keeping track of where you came from:

    user-management.php:

    $_SESSION['came_from'] = 'user-management.php';
    

    and then in your manage-user.php script:

    <a href="<?php echo $_SESSION['came_from'] ?>">Back</a>
    

    This is more reliable than using the HTTP referer, because not everyone sends refers, or sends the ACTUAL referer.

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

报告相同问题?

悬赏问题

  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?