Setting to Target an iFrame on Another Web Page
The first page is a simple HTML file which will hold the form that we will use to submit the respective data. The form can be something simple like this.
Page 1 code
|<form action="Page2.php" method="post">|
|<label for="text">Input Label:</label>|
|<input type="text" name="text" id="text">|
|<input type="hidden" name="page2control" value="authorized">|
|<input type="submit" value="Submit">|
We will then create another page that can be processed server side. Aside from processing the post data from the form, this file will be used to create a mirror of the form from the first page only this time it will change the target to the iFrame which is now embedded on the same file.
Page 2 code
|// validate input is from the form.|
|// Note: no other validations have been done|
|if ($_POST["page2control"] == "authorized")|
|<form id="page2form" target="iframe-name" method="post" action="process-form-data.php">|
|<input name="text" value="<?= $_POST['text'] ?>">|
There you have it. A simple way to send HTML form post data to an iFrame embedded on separate page.