shackwm60 Posted January 25, 2014 Share Posted January 25, 2014 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 Quote Link to comment https://forums.phpfreaks.com/topic/285666-php-in-iframe/ Share on other sites More sharing options...
Ch0cu3r Posted January 25, 2014 Share Posted January 25, 2014 (edited) 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 January 25, 2014 by Ch0cu3r Quote Link to comment https://forums.phpfreaks.com/topic/285666-php-in-iframe/#findComment-1466516 Share on other sites More sharing options...
shackwm60 Posted January 25, 2014 Author Share Posted January 25, 2014 <?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. Quote Link to comment https://forums.phpfreaks.com/topic/285666-php-in-iframe/#findComment-1466530 Share on other sites More sharing options...
Solution Ch0cu3r Posted January 25, 2014 Solution Share Posted January 25, 2014 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" ...> Quote Link to comment https://forums.phpfreaks.com/topic/285666-php-in-iframe/#findComment-1466536 Share on other sites More sharing options...
shackwm60 Posted January 25, 2014 Author Share Posted January 25, 2014 Wow! that was simple. It worked. Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/285666-php-in-iframe/#findComment-1466543 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.