Results 1 to 5 of 5

Thread: php layout help!

  1. #1
    Join Date
    Apr 2006
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default php layout help!

    Can someone help make an index page (backstageneopets.com/index.php) that has an iframe and if a user goes to index.php?frame=23 then the page will load 23.html(same floder as the index) in the iframe? I would also like the index page to have the layout found at http://www.backstageneopets.com/pass_save/layout/ (username: Username pass: apple35 , CaSe SeNtIvE) Lastly I don't know any php so if you could write things in a way that I could understand it, I would be very appreciative.

    Thanks so much!

  2. #2
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Simply:
    Code:
    <iframe
     src="<?php echo($_GET['frame']); ?>" name="main" frameborder="0" height="999"
     width="438">
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  3. #3
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    Assuming you can place php in the right spot on a page, the layout doesn't matter.

    Here's the answer:

    What you're talking about is called "GET". index.php?var=value.

    To get GET values (heh), just use "$_GET['varname']".

    This is ALL you need to do for what you're talking about.

    1. Find your iframe tag.
    2. Place the following code in it:
    PHP Code:
    <iframe src="http://path/<?php echo $_GET['frame']; ?>.html">
    All that php does is "echoes" (outputs) whatever "?frame=this" is.
    Change the path, .html, etc to your liking.
    This will work with anything in the address bar.

    However, the one catch is that if someone were to put "?frame=JSDFKL", then it would give an error... 404 in the frame.

    You could have a code check if the page is valid. A bit more complex though.


    Something like this:

    PHP Code:
    <?php
    $url 
    $_GET['frame'].".html";
    if (
    file_exists($url)) { $link $url; }
    else { 
    $link "default.html"; }
    ?>
    And put:<? echo $url; ?> where you want the url to go (inside the iframe tag, after src="...


    EDIT: Darn you, Twey... beat me to it. Ha.

    Same code, by the way, nekng. Use either... and use my second one if checking is important to you.

  4. #4
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    You could have a code check if the page is valid. A bit more complex though.
    There's no need. It doesn't pose a security risk, and if the user starts fiddling around with GET variables on the URI, s/he can expect to break things; there's no need to cater for that possibility.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  5. #5
    Join Date
    Apr 2006
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    perfect, thankx!

Bookmarks

Posting Permissions

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