Results 1 to 4 of 4

Thread: iframe help

  1. #1

    Thread Starter
    Lively Member DJ P@CkMaN's Avatar
    Join Date
    Jan 2002
    Location
    Burpengary, Queensland, Australia
    Posts
    95

    iframe help

    hey all,
    my site is a GUI with links that change the site displayed in an iframe in the center. is there a way that i can make it so i can have in the URL a way to change the site? like

    http://djclan.auscstrike.com/index.php?$page=downloads

    will make downloads.php come up in the iframe? could you do it like this?

    <iframe src="<?php echo $page; ?>" height="xx" width="xx">

    i really have no idea, that was just a suggestion from a newbie PHP person

    could you PLEASE help me??

    thanks
    There's something I've noticed in the last year or so...
    Australian's are good at EVERYTHING !!!

  2. #2
    Fanatic Member cpradio's Avatar
    Join Date
    Apr 2002
    Posts
    616
    if you wanted to do that it would be like so:

    PHP Code:
    <a href="?page=downloads">Downloads</a>

    <?php
     
    if (isset($_GET['page']))
      
    $iframe $_GET['page'];
     else
      
    $iframe "default.php";
    ?>
    <iframe src="<? echo $iframe; ?>">
    http://cpradio.net/
    Administrator @ WDForums and a Moderator @ WebXpertz City Forums

  3. #3

    Thread Starter
    Lively Member DJ P@CkMaN's Avatar
    Join Date
    Jan 2002
    Location
    Burpengary, Queensland, Australia
    Posts
    95
    thanks heaps man, it works great. im going to have a play to see if i can add some kool stuff.

    thanks
    There's something I've noticed in the last year or so...
    Australian's are good at EVERYTHING !!!

  4. #4
    Fanatic Member cpradio's Avatar
    Join Date
    Apr 2002
    Posts
    616
    Just one thing for you to ensure not doing is including the file extension inside the URL. That is a security hazard unless the files you are including are in a specific directory.

    Example:
    PHP Code:
    <a href="?page=downloads.php">Downloads</a>

    <?php
     
    if (isset($_GET['page']))
      
    $iframe $_GET['page'];
     else
      
    $iframe "default.php";
    ?>
    <iframe src="<? echo $iframe; ?>">
    The problem with this is someone can include their own script in your site by typing this on your site:
    ?page=http://mysite.com/myscript.php

    A way to avoid that is using either of these methods:
    1) Add the extension of the file as you include it
    PHP Code:
    <a href="?page=downloads">Downloads</a>

    <?php
     
    if (isset($_GET['page']))
      
    $iframe $_GET['page'];
     else
      
    $iframe "default";
    ?>
    <iframe src="<? echo $iframe . ".php"; ?>">
    2) Force the file to be located in a particular directory
    PHP Code:
    <a href="?page=downloads.php">Downloads</a>

    <?php
     
    if (isset($_GET['page']))
      
    $iframe $_GET['page'];
     else
      
    $iframe "default.php";
    ?>
    <iframe src="includes/<? echo $iframe; ?>">
    -Matt
    http://cpradio.net/
    Administrator @ WDForums and a Moderator @ WebXpertz City Forums

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width