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
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>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.