How to keep all the POST information while redirecting in PHP?

后端 未结 6 1673
感动是毒
感动是毒 2020-12-03 18:30
header(\'Location: \' . $uri);

This will miss all the $_POST information.

6条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-03 19:00

    You could save the post data in the session, redirect, and then retrieve it back from the session.

    session_start();
    $_SESSION['POSTDATA'] = $_POST;
    header('Location: ' . $uri);
    

    Then in the PHP file for the new location, retrieve the post data like this:

    $_POST = $_SESSION['POSTDATA'];
    

提交回复
热议问题