How to implement 303 redirect?

后端 未结 2 1367
没有蜡笔的小新
没有蜡笔的小新 2021-01-21 05:05

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         


        
相关标签:
2条回答
  • 2021-01-21 05:27

    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.

    0 讨论(0)
  • 2021-01-21 05:28

    You can do it other ways rather then passing the parameters in the url.

    1. Send the form.
    2. After checking valid values, Store the result in a database, session as you would normally do.
    3. Redirect
    4. Retrieve from the database or session.
    5. Use htmlentities() on the output.
    0 讨论(0)
提交回复
热议问题