7
11

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

PHPでPOSTリダイレクト

Last updated at Posted at 2019-07-15

PHPでPOSTリダイレクトする場合はパラメータを指定して渡すことはできないようです。その代わりに、引き継ぐようにして渡すことが可能です。

input.php
<form action="redirect.php" method="post">

    メール<input type="text" name="email">
    <input type="submit">

</form>
redirect.php

    header('Location: https://example.com/post.php', true, 307);

post.php

    echo $_SERVER["REQUEST_METHOD"] . '<br>';
    var_dump($_POST);

POST
array(1) { ["email"]=> string(3) "test@example.com" }

参考リンク:
ステータス303と307 - Do You PHP はてな
リダイレクト時のステータスコードには何を使えばいいか? | 株式会社シンメトリック公式ブログ |

7
11
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
11

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?