...

View Full Version : Passing variables through the URL inside frames



ThatPHPGuy
10-04-2003, 10:37 PM
I'm trying to pass a variable to my PHP script which is in a frame. I'm using <frame SRC="selectpage.php?page=14" NAME="bottom"> to do it. If I access the page through a normal URL, outside of frames, it gets the value of $page correctly, no problem. But inside of the frame, $page is undefined. How do I get this variable's value?

Please help me, this is driving me crazy.

Rich

Nightfire
10-04-2003, 11:19 PM
Using frames or not shouldn't effect anything to do with php.

mordred
10-04-2003, 11:26 PM
Your problem is rather weird. What you did was correct. Post a short test case that shows the issue so we can have a detailed look at it.

ThatPHPGuy
10-05-2003, 12:59 AM
OK, now all the sudden my initial value of 14 is actually coming through. I'm not sure why it wasn't before. But when I click on a button to move to a different page, then things get broken and $page becomes a null value. Normally this code won't show the user the values of $page and $prevpage, i put them in for debugging purposes.

Here's the code I've got:

<?

$prevpage=$page-1;
echo
"
<html>
<body bgcolor=\"#000000\">
<font color=\"#ffffff\">
page=$page
prevpage=$prevpage
</font>
<form>
<input type=\"image\" src=\"img/firstbutton.jpg\" height=\"48\" width=\"73\" border=\"0\" alt=\"go to first page\"
onClick=\"parent.frames[0].location='page1.html';
parent.frames[1].location='selectpage.php?page=1';\">
";
if ($prevpage>0)
{
echo
"
<input type=\"image\" src=\"img/backbutton.jpg\" height=\"48\" width=\"73\" border=\"0\"
alt=\"go to previous page\"
onClick=\"parent.frames[0].location='page$prevpage.html';
parent.frames[1].location='selectpage.php?page=$prevpage';\">
";
}
else
{
echo
"
<img src=\"img/backbutton.jpg\" height=\"48\" width=\"73\" border=\"0\" alt=\"you can't go back one page\">
";
};
echo
"
</form>
</body>
</html>
";

?>

ThatPHPGuy
10-05-2003, 02:45 PM
Never mind. I was guilty of idiocy yesterday. A form was not the solution. All it needed was links, with the onClick handler in javascript added.

D'OH!!!!!!!

But I did get the problem fixed. That's the good news.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum