php code running in a hidden iframe

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Da_Elf
Forum Commoner
Posts: 81
Joined: Mon Dec 29, 2008 12:31 pm

php code running in a hidden iframe

Post by Da_Elf »

First off im not sure which part of the forum this belong since its both a javascript and php problem.

Ive got a page which has a div set to hidden. in the div is an iframe which contains a small form. Using javascript on the parent page you can click a link that unhides the div showing the form. you can also click outside the div to hide it again using a simple javascript function i call hideForm(). For the form thats in the child window (the iframe) i want that when you click submit the form submits to itself, does the needed code, then refreshes the form and hides it again ready and waiting for when its called up again. I will simplify my code here. What is wrong with it is that it hides the div calling on the javascript in the parent window. but doesnt refresh the iframe page named contact.php.

found this error in my logs
[07-Oct-2013 09:03:42] PHP Warning: Cannot modify header information - headers already sent by (output started at /**************/contact.php:91) in /home1/elfproth/public_html/gspdesign/contact.php on line 95
on line 95 was where my html code has its <head> element

Code: Select all

<?php
if(isset($_POST['send'])){
/*if errors exist return to form using header('Location:contact.php');die();
if not then run the things needed. this works*/
echo "<script language='javascript'>window.parent.hideForm();</script>"; //this works as well
header('Location:contact.php');die(); //this doesnt work... just tested removing the javascript and this then works. but not when the javascript is enabled
}
?>
<form action="contact.php" method="post">
<!-- form elements -->
<input type="submit" name="send"  />
</form>
}

Last edited by Da_Elf on Mon Oct 07, 2013 10:36 am, edited 1 time in total.
Da_Elf
Forum Commoner
Posts: 81
Joined: Mon Dec 29, 2008 12:31 pm

Re: php code running in a hidden iframe

Post by Da_Elf »

correct me if im wrong but if the div with the iframe is set to "visibility:hidden;" the code in the iframe should still be able to run right?
Da_Elf
Forum Commoner
Posts: 81
Joined: Mon Dec 29, 2008 12:31 pm

Re: php code running in a hidden iframe

Post by Da_Elf »

ok never mind. tried a bunch of different things then just decided that when the parent page loads the hidden div is empty. no i-frame. you you click the link that the javascript unhides the div it also creates the iframe elements at the same time. so after the form has been submitted i was able to get the javascript to work but not the refresh. so all i did was add some javascript that destroys the iframe while its hiding the div the iframe was in.
Post Reply