Redirecting to the referrer on form submission

后端 未结 2 1685
我在风中等你
我在风中等你 2021-01-19 06:43

There are multiple pages. There are links on these pages. These links leads to a page with a form. When the form is submitted, the page that holds the form refreshes itself

2条回答
  •  滥情空心
    2021-01-19 07:21

    This concept is known as Post-Redirect-Get. The question is: is the user always going back to the same static original page, or are there many pages that can lead the user to this form? If the latter is true, simply add the referer ($_SERVER['HTTP_REFERER']) as a form element to record where they came from. php code:

    redirect($_SERVER['PHP_SELF']);
               }
               else {
                  $this->redirect("original-user-location", true, 303);
               }
            }
            private function redirect($loc) {
               header("Location: $loc", true, 303);
               exit;
            }
            //ignore PUT, DELETE
            public function __call($_, $_) {}
         }
         controller::_()->$_SERVER['REQUEST_METHOD']();
      ?>
    

提交回复
热议问题