0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

勉強メモ:PHPの画面遷移時の処理実行判断について

Last updated at Posted at 2025-07-03

学んだこと

phpで画面遷移を強制的に行いたい場合、
header("Location: ./index.php");
を用いるとよい。

強制的に指定ページにリダイレクトさせるため、戻るボタンで戻ったさいにダブって処理をさせない。

● 例

test-1.php

action.php

test-2.php

header("Location: ./index.php");を処理用のページ(action.php)に用いて、test-2.phpにリダイレクトさせる。

またこの時、test-1.phpからURIをPOSTして、preg_muchなどで判定したのち、処理を実行するようにすると、test-1.phpからの遷移時のみに処理が実行することができる。

0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?