开发者

Form submit to iframe on new page

开发者 https://www.devze.com 2022-12-12 15:42 出处:网络
I have a form which开发者_Go百科 submits to an iframe, This works fine if you are on a page with the iframe.

I have a form which开发者_Go百科 submits to an iframe, This works fine if you are on a page with the iframe.

I want to be able to have the form on any page and when submit is pressed load a page and send the submit to the iframe

e.g.

  1. On page "article.php" and press submit
  2. Open page "results.php" and
  3. Send post data from form clicked in "article.php" to iframe "DataHere" on "results.php"

Thanks in advance


You could try detecting if the frame exists when the form is submitted and if it does not, reload the whole page and generate the iFrame.

If you need a hand checkout http://www.java-scripts.net/javascripts/Check-Frames-Page-Script.phtml


If you are able to comfortably sanitize your initial POST data to avoid XSS, you could create an intermediate page for your iframe destination that does your POST for you:

  1. On page article.php with <form action="results.php">, press submit.
  2. results.php validates that the input isn't XSS, and renders with a <iframe src="negotiator.php?my=form&data=here"></iframe>
  3. negotiator.php takes the query string arguments (and runs the same sanitizing as results.php) and POSTs them to your intended url.
  4. Your results will load in the iframe.

It's pretty important that you make sure your input isn't insane. If your form requires arbitrary text, punctuation, and special characters, this is not safe for you.

0

精彩评论

暂无评论...
验证码 换一张
取 消