Current location: Hot Scripts Forums » Programming Languages » PHP » using GET to load file into an iframe


using GET to load file into an iframe

Reply
  #1 (permalink)  
Old 02-22-07, 12:21 PM
sondogg's Avatar
sondogg sondogg is offline
Newbie Coder
 
Join Date: Feb 2006
Posts: 59
Thanks: 0
Thanked 0 Times in 0 Posts
using GET to load file into an iframe

Hey everyone,

Sorry if I have a hard time explaining this. The index page of the site I'm building has a navigation section at the top 2 iframes in the middle (left and right) and a footer at the bottom. Currently the navigation links target a specified file in one or both of the iframes.

What I would like to accomplish is to be able to have the ability to have a link from anywhere (myspace, email, etc...) that will load the index page and the iframes would load the pages that I want loaded.

So I believe I would need some sort of "if else" statement so that I could use both the navigation links (which I believe would be using POST?) and the address bar in the browser would be able to point to a page I specify in an external link (using GET method).

Here is an example:

If the address bar had this info:
http://www.mysite.com/index.php?left...ight=right.php

The left iframe would load "left.php" and the right iframe would load "right.php."

Does this make sense?

Sonny
Reply With Quote
  #2 (permalink)  
Old 02-22-07, 01:57 PM
Shaffer Shaffer is offline
Wannabe Coder
 
Join Date: Sep 2006
Location: Israel
Posts: 149
Thanks: 0
Thanked 0 Times in 0 Posts
Hello,
let me see...
PHP Code:

<?php

  $lframe 
$_GET['left']; // (left iframe).
  
$rframe $_GET['right']; // (right iframe).
  
echo "<iframe src=\"$lframe\" class=\"left_style\"/><br/>\r\n";
  echo 
"<iframe src=\"$rframe\" style=\"right_style\"/><br/>\r\n";
?>
__________________
Hello from Israel!
Reply With Quote
  #3 (permalink)  
Old 02-22-07, 03:42 PM
sondogg's Avatar
sondogg sondogg is offline
Newbie Coder
 
Join Date: Feb 2006
Posts: 59
Thanks: 0
Thanked 0 Times in 0 Posts
Hey thanks for your help! Although I ended up changing your script to work how I needed it, you got me going in the right direction.

Here is what I did to make it work:

PHP Code:

<table width="100%">
<tr>
<td>
<?php 
if ( (isset($_GET['left'])) ) { 
    
$lframe $_GET['left'];
}

else {

    
$lframe "left.php";
    }
    
if ( (isset(
$_GET['right'])) ) { 
    
$rframe $_GET['right'];
}

else {

    
$rframe "home.php";
    }

 
/* $lframe = $_GET['left']; // (left iframe). 
  $rframe = $_GET['right']; // (right iframe). */
?>
<iframe name="left" src=<?php echo "\"$lframe\""?> frameborder="0" width="270" height="400" scrolling="no"></iframe></td>
<td width="15" background="../images/dots_vert.gif"></td>
<td><iframe name="right" src=<?php echo "\"$rframe\""?> frameborder="0" width="390" height="400" scrolling="auto"></iframe></td>
</tr>
</table>
Reply With Quote
  #4 (permalink)  
Old 02-23-07, 06:19 AM
Shaffer Shaffer is offline
Wannabe Coder
 
Join Date: Sep 2006
Location: Israel
Posts: 149
Thanks: 0
Thanked 0 Times in 0 Posts
Hello,
good job with the code. I am happy it worked for you, and ofcourse I am glad I could help.
Plus, I like how you programmed "safely", meaning, that you check to see if the variables are set, etc.
If you want any further help, like making a form to post the information for it, just mention it below.


Shaffer.
__________________
Hello from Israel!
Reply With Quote
  #5 (permalink)  
Old 02-23-07, 06:22 AM
scott2500uk's Avatar
scott2500uk scott2500uk is offline
Coding Addict
 
Join Date: Apr 2006
Posts: 275
Thanks: 2
Thanked 2 Times in 2 Posts
just a code tip instead of having:

src=<?php echo "\"$rframe\""; ?>

change it to:

src="<?=$rframe?>"
Reply With Quote
  #6 (permalink)  
Old 02-23-07, 06:27 AM
Shaffer Shaffer is offline
Wannabe Coder
 
Join Date: Sep 2006
Location: Israel
Posts: 149
Thanks: 0
Thanked 0 Times in 0 Posts
Hello,
I was acually going to say that, but I think that not all servers allow it.
__________________
Hello from Israel!
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
External link to iframe Techmom HTML/XHTML/XML 7 07-23-09 12:57 PM
Heres one, mysql statement to load a table with a file from ftp?? 0o0o0 PHP 8 04-28-06 01:32 AM
Error message not getting displayed. sanjeet Windows .NET Programming 0 12-20-05 10:48 AM
load a file within a webpage with a link digitalf PHP 8 06-25-04 10:49 PM
How to write a php script to load a text file into a table automatically? xmxpcom PHP 2 02-12-04 08:37 AM


All times are GMT -5. The time now is 05:57 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.