Jump to content

[SOLVED] Need help with form and iframe


GT2007

Recommended Posts

Hello,

I hope that someone can help me with a little problem I am having with form and iframe.

 

What I am trying to do is use a form to submit to the page that it is on, and also to a page that is in an iframe that is on the same page. The problem that I am having is that the information from the form is only hitting the page that it is on and not sending the information to the page in the iframe. I am using this $item = $_POST['item']; on the main page, and it is also in the page that is being pulled up in the iframe.

 

Here is the form:

<form name="search" method="post">
<input name="item" type="text" value="" size="50" maxlength="100"> 
<input type="submit" name="Submit" value="Search">
</form>

Here is the PHP info at the top of the page that the form is on, and the page that the iframe is calling:

<?php
  include "config.php";
$item = $_POST['item'];
if (!$item) {$item ="$DefaultItems";}
   ?>

If you have any ideas to throw my way I sure would appreciate it TIA...

Link to comment
https://forums.phpfreaks.com/topic/40110-solved-need-help-with-form-and-iframe/
Share on other sites

As your form and iframe are in the same page, you are calling another page to iframe. so there is no possiblity to get the request variable in the called page. you have to pass the value of the $item to the called page each time.

 

use something like this:

 

$item = $_POST['item'];
......

<iframe src="mypage.php?item=<?= $item ?>"></iframe>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.