Jump to content


Photo

php in iFrame


Best Answer Ch0cu3r, 25 January 2014 - 12:26 PM

Try setting the iframe src attribute to an absolute url path.

<script type="text/javascript">document.write(unescape(... src\"http://site.com/papatientInfoForm.php\" ...
...
<iframe ... src="http://mysite.com/patientInfoForm/patientInfoForm.php" ...>
Go to the full post


  • Please log in to reply
4 replies to this topic

#1 shackwm60

shackwm60

    Member

  • Members
  • PipPip
  • 16 posts
  • Age:50

Posted 25 January 2014 - 10:20 AM

hello all, noob here hope you can help.

 

I have a web form that is loaded into an iFrame. I want to modify that form a bit and added some php (primarily to bring in a session variable)

 

My problem is, I cant get ANY php to execute at all. I have even tried a simple one line  <?php echo "this is a test" ?> and it doesn't work.  If I call this page directly instead of inside the iFrame, Everything displays as expected, even the session variables. I get no error messages displayed.

 

Yes, I have added session start and even that ie header tag that's been recommended.

 

Anyone seen this behavior before

 

I am running this on Ubuntu 12.0.4 with php 5.3.10

 



#2 Ch0cu3r

Ch0cu3r

    Advanced Member

  • Moderators
  • 2,303 posts

Posted 25 January 2014 - 10:43 AM

What url are you using for the iframe? and the parent frame/window? As long as the url for the parent window is a http request to a server that is configured with PHP then it should work fine.

 

Can you post your code also?


Edited by Ch0cu3r, 25 January 2014 - 10:44 AM.


#3 shackwm60

shackwm60

    Member

  • Members
  • PipPip
  • 16 posts
  • Age:50

Posted 25 January 2014 - 11:56 AM

<?header('P3P: CP="CAO PSA OUR"'); ?>
<?php require_once("../includes/session.php"); ?>

<!DOCTYPE HTML>
<html>
  
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <!-- Start of the headers for CoffeeCup Web Form Builder -->
    <meta name="viewport" content="width=device-width, initial-scale=1.0"
    />
    <script type="text/javascript" src="common/js/form_init.js" data-name=""
    id="form_init_script">
    </script>
    <link rel="stylesheet" type="text/css" href="theme/sky_responsive/css/default.css?version=390"
    id="theme" />
    <!-- End of the headers for CoffeeCup Web Form Builder -->
    <title>
      patientInfoForm
    </title>
  </head>
  
  <body><!-- Start of the body content for CoffeeCup Web Form Builder -->
  
      <-- after this there is a LONG area of standard form config.. -->
      <-- then some php inserted.. but never shows up -->
        
      <?php echo "this is a test" ?>
      
      
      
  </body>
  
  </html>    
      
<script type="text/javascript">document.write(unescape("%3Ciframe id=\"fb_iframe\" src=\"patientInfoForm.php" + window.location.search + "\" width=\"100%\" height=\"6610\"allowtransparency=\"true\" scrolling=\"no\" frameborder=\"0\"%3E&lt;a href=\"patientInfoForm.php\" title=\"patientInfoForm\"&gt;Check out my CoffeeCup Form&lt;/a&gt;%3C/iframe%3E"));</script>
<noscript>
  <iframe height="6610" style="border:none; background:transparent; overflow:hidden; width:100%;"
  id="fb_iframe" src="patientInfoForm/patientInfoForm.php">
    &lt;a href="patientInfoForm.php" title="patientInfoForm"&gt;Check out
    my CoffeeCup Form&lt;/a&gt;
  </iframe>
</noscript>

So, the code up top is the target page (patientInfoForm.php) and the code on the bottom is generated from an app from Coffecup software (above) and is inserted in the calling page. its all on the same server so is not making a call outside the domain at all.  The form itself displays and works as expected when not in the iFrame.

 

For easy reading ive removed all the excess form code from that page. Behavior is the same. thanks.

 

 

 

 



#4 Ch0cu3r

Ch0cu3r

    Advanced Member

  • Moderators
  • 2,303 posts

Posted 25 January 2014 - 12:26 PM   Best Answer

Try setting the iframe src attribute to an absolute url path.

<script type="text/javascript">document.write(unescape(... src\"http://site.com/papatientInfoForm.php\" ...
...
<iframe ... src="http://mysite.com/patientInfoForm/patientInfoForm.php" ...>


#5 shackwm60

shackwm60

    Member

  • Members
  • PipPip
  • 16 posts
  • Age:50

Posted 25 January 2014 - 12:58 PM

Wow! that was simple. It worked. Thanks!






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

Cheap Linux VPS from $5
SSD Storage, 30 day Guarantee
1 TB of BW, 100% Network Uptime

AlphaBit.com