dongye7231 2011-04-19 14:43
浏览 13
已采纳

带消息的PHP重定向

I have a controller which displays and processes postback for a form. The controller redirects to another page once the form has been successfully validated and the data has been processed accordingly.

Redirection is completed with something to the equivalent of:

@header('Status: 303 See other');
@header('Location: ' . $redirect_uri);

What is the most reliable way for the controller to provide a message that is to be displayed on the new page? Is there a standard practice for this?

i.e. "Your account was successfully updated."

My thought is to place dynamically generated messages into a session variable, and to indicate a predefined message with a unique ID in the URI itself:

$_SESSION['previous-response-msg'] = "Account of '$user_name' was updated.";

or

$redirect_uri = 'http://example.com/other-page?msg=42';
  • 写回答

4条回答 默认 最新

  • dsa99349 2011-04-19 14:46
    关注

    One time message in session variable has worked fine for me. I don't see much of a problem here, especially for status type messages.

    If you are using a framework, its quite possible this is built in. .

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

报告相同问题?

悬赏问题

  • ¥60 用visual studio编写程序,利用间接平差求解水准网
  • ¥15 Llama如何调用shell或者Python
  • ¥20 谁能帮我挨个解读这个php语言编的代码什么意思?
  • ¥15 win10权限管理,限制普通用户使用删除功能
  • ¥15 minnio内存占用过大,内存没被回收(Windows环境)
  • ¥65 抖音咸鱼付款链接转码支付宝
  • ¥15 ubuntu22.04上安装ursim-3.15.8.106339遇到的问题
  • ¥15 blast算法(相关搜索:数据库)
  • ¥15 请问有人会紧聚焦相关的matlab知识嘛?
  • ¥15 网络通信安全解决方案