i got the problem of accessing variable outside iframe.

//a.php
<?php
$a="text";
?>
<iframe src="b.php"></iframe>

//b.php
<input type="text" value="<?php //i want $a to be put here ?>" />

Is it possible to access $a from b.php?

Member Avatar for diafol

Hmm. You could use a session variable and get javascript to refresh the iframe.
I think this was an early method for ajax.

You don't even have to use a session variable though, you could pass the variable as a querystring (although I think you're limited to length here). Quite a few ways you could do it I suppose.

Are you not able to use an include file for b.php?

<?php
$a="text";

include("b.php");

?>

actually i wish to put some tables into b.php but it will mess up my divs if i use include directly.

Member Avatar for diafol

Really? I'd look at how a.php b.php are formed in that case. Using an iframe is not the way to go (IMO).

ok, solved. i assign value through a form.

//a.php
<form action="b.php" target="frame" method="post" >
<input type="hidden" name="hide" value="<?php echo $a; ?>" />
<input type="submit" value="Go" name="go" />
</form>
<iframe src="b.php" id="frame" name="frame">
</iframe>

//b.php
<input type="text" value="<?php echo $_POST[hide]; ?>">

If solved ? Then mark it as 'Solved' with below link 'Mark as Solved' or something similar.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.