Reputation: 1
So I have a form:
<fieldset>
<legend>Post a comment:</legend>
<form target="forum" method="post" action="forum.php">
//Targeting the iframe in my form (`<form target="forum"`) & Submitting the form to my PHP file (`action="forum.php"`)
Name: <br />
<input type="text" name="fname" /><br />
Subject:<br />
<input type="text" name="subject" size="50"/><br />
Comment:<br />
<textarea name="comment" rows="10" cols="100">Hello,</textarea><br />
<input type="submit" value="Send" />
<input type="reset" value="Reset" />
</fieldset>
</form>
Then I want to take the text data (name, subject and comment) and put that into an iframe on the click of a button <input type="submit" value="Send" />
...
The iframe is on the same page as the form (below it) and looks like this...
<iframe name="forum" src="forum.php"
width="900" height="500" ></iframe>
Once the text data has been inputted I wanted the iframe to store that data there permanently. Basically like a forum within an iframe.
How do I process the form in the php file and spit out the result into the iframe?
Upvotes: 0
Views: 1926
Reputation: 38147
make the source of the iframe forum.php and include the parameters in the URL ? use $_GET in PHP to get the parameters ?
<iframe id="myiframe" src="forum.php?fname=blah&subject=blah"></iframe>
So you would use javascript to change the src of the iFrame on the submit of the form :
document.getElementById['myiframe'].src = "forum.php?fname=blah&subject=blah";
then in PHP get the variables and do what you need todo with them to produce the desired output:
$fname = $_GET['fname'];
$subject = $_GET['subject'];
// do some processing
Upvotes: 3