drhzc64482 2011-06-27 18:28
浏览 14
已采纳

存储重定向URL以供以后使用

I'm trying to store the redirect URL for use a few pages later but I'm having trouble figuring out how to get it from one place to another.

Usually I'd just pass a variable thru the URL, but since my redirect URL contains URL variables itself, this doesn't exactly work.

To give you a better idea of what I'm trying to do, here's the structure.

PAGE 1: User can click a link to add content on PAGE 2

PAGE 2: User enters text. Submitting the form on this page calls "formsubmit.php" where the MySQL data entries are handled. At the end of this I need to redirect the user to PAGE 1 again. The redirect URL needs to exactly match what was originally on PAGE 1

Does anyone have any suggestions on how to go about this?

  • 写回答

5条回答 默认 最新

  • duanlinzhen7235 2011-06-27 18:31
    关注

    You should use $_SESSION to store the variable in session memory. As far as specifics go with how to handle this in particular, you should be able to figure it out (store the variable, check if it exists later, if so redirect etc etc) but $_SESSION is going to be much more efficient / less messy than trying to pass things back and forth in query strings.

    To declare a session variable you would do something like this:

    $_SESSION['redirUrl'] = "http://www.lolthisisaurl.com/lolagain";
    

    And then to reference it you just do

    $theUrl = $_SESSION['redirUrl'];
    

    Here is some material to get you started: http://php.net/manual/en/reserved.variables.session.php

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

报告相同问题?

悬赏问题

  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?
  • ¥15 求daily translation(DT)偏差订正方法的代码
  • ¥15 js调用html页面需要隐藏某个按钮
  • ¥15 ads仿真结果在圆图上是怎么读数的
  • ¥20 Cotex M3的调试和程序执行方式是什么样的?
  • ¥20 java项目连接sqlserver时报ssl相关错误
  • ¥15 一道python难题3
  • ¥15 牛顿斯科特系数表表示
  • ¥15 arduino 步进电机
  • ¥20 程序进入HardFault_Handler