PHP: Persist form data across redirect -


I have an existing website that has many references to it. We want to apply https to pages, so I added a simple code snippet:

  if ($ _ SERVER ["HTTPS"]! = "At") {dead (header (" Location: Https: // ". $ _SERVER [" HTTP_HOST "]. $ _SERVER [" REQUEST_URI "])); Go out(); // To make sure that the script prevents here, in the case of the bus)   

This works, except that many files have self-referenced forms with HTML in action. For example, on page.php:

  & lt; Form action = "http://domain.com/page.php" method = "post" & gt; & Lt; Input type = "text" name = "sample" /> & Lt; Input type = "submit" value = "next" /> & Lt; / Form & gt;   

Do I have any way to apply this redirect snippet without breaking all these forms?

No, You can not be redirected only because you are submitting unsafe content in any way, since redirects to https will be meaningless since the request has already appeared.

You should use the relative URL. Where / is the same as the domain name

/ = domain.com

/ Page> = domain.com/page

The leading / URL is equivalent to the current URI (zero query works): Therefore, http://domain.com/page -

By action: foo = http: // Domain.com/page/foo

Actions: / foo = http://domain.com/foo

to http or https Will be preserved in this way.

Another way is to move the domain with 2 slash actions: // domain.com However I do not get the old IE version to get it.

Comments

Popular posts from this blog

excel vba - How to delete Solver(SOLVER.XLAM) code -

github - Teamcity & Git - PR merge builds - anyway to get HEAD commit hash? -

ios - Replace text in UITextView run slowly -