Passing a variable to an iframe

Discussion in 'PHP' started by karl_murphy, Apr 24, 2008.

  1. #1
    I'm trying to pass a variable through a URL to an iframe, which in turn should pass the variable to the iframe source script. Getting the variable from the URL to the iframe is not a problem and this seems to be working fine. However, the variable doesn't seem to be being passed to the iframe source script.


    This is the link, which passes the variable along the URL to the iframe. This is working fine:
    echo "<th align = right colspan = 3><font face = 'arial'><a href = 'http://www.thedatacentre.org/rms/v2/homepage/forward_message.php?msg_id=$msg_id' style='text-decoration:none'>Forward</a></font>\n";
    PHP:

    This section of the iframe script is the link to the iframe source script.
    <iframe src="http://www.thedatacentre.org/rms/v2/homepage/forward_message_frame.php?msg_id=<?php $msg = $_GET['msg_id'];?>" name="forwardiframe" width="100%" height="450" border="0" frameborder="0" scrolling="no" ></iframe>
    PHP:
    As you can I am trying to pass the variable to the source using the $_GET method. When the page loads it appears as though the variable is being sent as you can see the progress of the transaction at the bottom of the screen, however, I've tried echoeing the variable + the screen is blank.

    Any ideas?
     
    karl_murphy, Apr 24, 2008 IP
  2. jestep

    jestep Prominent Member

    Messages:
    3,659
    Likes Received:
    215
    Best Answers:
    19
    Trophy Points:
    330
    #2
    Do you see that the iframe has the correct url if you look at the source code?


    Should look like:
    <iframe src="http://www.thedatacentre.org/rms/v2/homepage/forward_message_frame.php?msg_id=1" name="forwardiframe" width="100%" height="450" border="0" frameborder="0" scrolling="no" ></iframe>
     
    jestep, Apr 24, 2008 IP
  3. karl_murphy

    karl_murphy Member

    Messages:
    82
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #3
    This is what I get when I view the source code, as you can see msg_id is blank:

    <iframe src="http://www.thedatacentre.org/rms/v2/homepage/forward_message_frame.php?msg_id=" name="forwardiframe" width="100%" height="450" border="0" frameborder="0" scrolling="no" ></iframe>
    HTML:
     
    karl_murphy, Apr 24, 2008 IP
  4. nihcer

    nihcer Member

    Messages:
    30
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    43
    #4
    are you trying to do something like

    ...msg_id=<?php echo $_GET['msg_id'];?>...
    PHP:
     
    nihcer, Apr 24, 2008 IP
  5. karl_murphy

    karl_murphy Member

    Messages:
    82
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #5
    Yes, but the variable doesn't seem to pass to the iframe source script.
     
    karl_murphy, Apr 24, 2008 IP
  6. nihcer

    nihcer Member

    Messages:
    30
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    43
    #6
    can you post the entire code
     
    nihcer, Apr 24, 2008 IP
  7. xrvel

    xrvel Notable Member

    Messages:
    918
    Likes Received:
    30
    Best Answers:
    2
    Trophy Points:
    225
    #7
    your frame drawer file.

    
    <?php
    $pass = $_GET['msg_id'];
    ?>
    <iframe src="yourscript.php?msg_id=<?php echo($pass)?>" name="forwardiframe">
    </iframe>
    
    PHP:
    ----------

    And in your yourscript.php
    
    <?php
    echo($_GET['msg_id']);
    ?>
    
    PHP:
    If the scripts above don't work (it should work), please copy the iframe target file source here :)
     
    xrvel, Apr 24, 2008 IP
  8. karl_murphy

    karl_murphy Member

    Messages:
    82
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #8
    That works great, thank you very much. I was trying something similiar, but couldn't seem to get it working. Consider your reputation boosted!
     
    karl_murphy, Apr 25, 2008 IP