Jump to content

php in iFrame


Go to solution Solved by Ch0cu3r,

Recommended Posts

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

 

Link to comment
https://forums.phpfreaks.com/topic/285666-php-in-iframe/
Share on other sites

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
Link to comment
https://forums.phpfreaks.com/topic/285666-php-in-iframe/#findComment-1466516
Share on other sites

<?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<a href=\"patientInfoForm.php\" title=\"patientInfoForm\">Check out my CoffeeCup Form</a>%3C/iframe%3E"));</script>
<noscript>
  <iframe height="6610" style="border:none; background:transparent; overflow:hidden; width:100%;"
  id="fb_iframe" src="patientInfoForm/patientInfoForm.php">
    <a href="patientInfoForm.php" title="patientInfoForm">Check out
    my CoffeeCup Form</a>
  </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.

 

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/285666-php-in-iframe/#findComment-1466530
Share on other sites

  • Solution

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" ...>
Link to comment
https://forums.phpfreaks.com/topic/285666-php-in-iframe/#findComment-1466536
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.