如何实现303重定向? [英] How to implement 303 redirect?

查看:172
本文介绍了如何实现303重定向?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道如何实现303重定向以显示发布数据。



示例:

 我发送表格。 

重定向

页面显示我刚发布的信息。 (例如:姓名,电子邮件)。

我认为它是通过参数完成的,比如 /index.php?name = TheName& email = theEmail 但我不确定,因为我试图找到一些好文章解释但不能。



<非常感谢。

解决方案

在PHP中,您可以使用 header()<执行303重定向/ code>:

  header(HTTP / 1.1 303 See Other); 
header(Location:http:// $ _ SERVER ['HTTP_HOST'] / new / location / here);

您可能遇到的问题是在重定向后保留表单信息。一种解决方案可能是使用 PHP会话变量来存储表单数据。



您可以使用参数重定向来传递提交的数据,但这不是我认为的干净解决方案。


I'd like to know how to implement 303 redirect for displaying post data.

Example:

I send the form.

Redirect

Page displays the info I just posted. (Eg: Name, email).

I think it is done with parameters, like /index.php?name=TheName&email=theEmail but i'm not sure, since I've tried to find some good article explaining it but couldn't.

Thanks a lot.

解决方案

In PHP you can perform a 303 redirect using header():

header("HTTP/1.1 303 See Other");
header("Location: http://$_SERVER['HTTP_HOST']/new/location/here");

The problem you may face is retaining the form information after the redirect. One solution might be using PHP session variables to store the form data.

You could redirect using parameters to pass the submitted data, but that isn't what I'd consider a 'clean' solution.

这篇关于如何实现303重定向?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆