0

Use PHP and MySQL. I have 2 websites, and want to show content on page of first website in the iframe of second website. In the page of first website, it requires POST variable submitted by form. How to sent the POST variable to iframe?

My concept in page of second website is something like this:

<html>
<body>
<form method="post" action="iframe1">
<select name="choice">
  <option value="1">1</option>
  <option value="2">2</option>
  <option value="3">3</option>
</select>
</form>
<iframe name="iframe1" src="first_website.com/page1.php?????????></iframe>
</body>
</html>

How to make iframe shows content of page using the choice variable?

AJ OP
  • 345
  • 2
  • 5
  • 16

1 Answers1

0

This is why GET was created so that you could pass your parameters in the URL:

<iframe name="iframe1" src="first_website.com/page1.php?choice=1"></iframe>

Then change the PHP code so that all $_POST[] variables are $_GET[] variables.

Another option:

Use an AJAX request to POST to the PHP script and then insert the AJAX response HTML/text into the iframe with javascript:

How to change iframe HTML with javascript

Community
  • 1
  • 1
Alex W
  • 37,233
  • 13
  • 109
  • 109