weemikey Posted July 31, 2007 Share Posted July 31, 2007 Hi all. Thanks to those who have tried to help me lately with iframes vs. php. So far I've got EVERYTHING working except one piece. Here's the scenario for those of you following along at home.... - I have an index.php that holds an iframe. Menu items simply call index.php using an href (target=parent) and pass in the name/content of the iframe. That all works. - I have a loginform.php (again, residing in the iframe, on index.php). When the user logs in I call logic for validating their profile in login.php. - if the login is successful and all the user/password stuff is good I want to redirect to index.php and the "Home" page. What's happening (of course) is that because loginform.php calls login.php WITHIN the iframe, index.php loads IN the iframe if I use "header" to redirect from login.php. The only way I've gotten this site to work is by making any LINKS (meaning clickable href's) target the parent. However, if I'm in a logic script that has only "header" as a way to redirect, it will only redirect within the iframe. Any thoughts? This is totally the last piece of the puzzle. Thanks for any help you can give! Quote Link to comment Share on other sites More sharing options...
Asperon Posted July 31, 2007 Share Posted July 31, 2007 I'm not sure how to do it , but you index page could detect whether or not its in a frame...and then from there have it open in _parent target or wherever you want it Quote Link to comment Share on other sites More sharing options...
Asperon Posted July 31, 2007 Share Posted July 31, 2007 actually have it send the login to itself like you are doing..and if teh login is correct, have it dispaly two links... a link that goes to the index and alink that logs you out <?php if(isset($_SESSION['validUser'])) { echo 'logged in'; <a href="business_view.php" target="_parent">Account Information</a> // THIS IS YOUR LINK TO YOUR INDEX PAGE } else { if(isset($userName)){ echo 'could not log you in'; } else{ echo 'you are not logged in.'; } echo '<form action="business_login.php" method="POST">'; echo '<table>'; echo '<tr>'; echo '<td>User Name</td>'; echo '<td><input type="text" name="userName" /></td>'; echo '</tr>'; echo '<tr>'; echo '<td>Password</td>'; echo '<td><input type="password" name="password" /></td>'; echo '</tr>'; echo '<tr>'; echo '<td><input type="submit" value="LOG IN" /></td>'; echo '</tr>'; echo '</table>'; echo '</form>'; } ?> <br/> <a href="logout.php">Log Out</a> </body> </html> Quote Link to comment Share on other sites More sharing options...
Asperon Posted July 31, 2007 Share Posted July 31, 2007 That would not be all of the code, you would ofcouse have to do $_POST variables and connect to you database etc...this is using $_SESSION variables actually have it send the login to itself like you are doing..and if teh login is correct, have it dispaly two links... a link that goes to the index and alink that logs you out <?php if(isset($_SESSION['validUser'])) { echo 'logged in'; <a href="business_view.php" target="_parent">Account Information</a> // THIS IS YOUR LINK TO YOUR INDEX PAGE } else { if(isset($userName)){ echo 'could not log you in'; } else{ echo 'you are not logged in.'; } echo '<form action="business_login.php" method="POST">'; echo '<table>'; echo '<tr>'; echo '<td>User Name</td>'; echo '<td><input type="text" name="userName" /></td>'; echo '</tr>'; echo '<tr>'; echo '<td>Password</td>'; echo '<td><input type="password" name="password" /></td>'; echo '</tr>'; echo '<tr>'; echo '<td><input type="submit" value="LOG IN" /></td>'; echo '</tr>'; echo '</table>'; echo '</form>'; } ?> <br/> <a href="logout.php">Log Out</a> </body> </html> Quote Link to comment Share on other sites More sharing options...
weemikey Posted July 31, 2007 Author Share Posted July 31, 2007 Hi! Thanks for your advice. I THINK what you're suggesting is the path I've already taken. Basically when the login is successful I've been redirecting to a "success" page where the user would click something to continue. The client wants the login to happen and if successful go STRAIGHT to the index/home page with no clicking. Bugger. Quote Link to comment Share on other sites More sharing options...
Asperon Posted July 31, 2007 Share Posted July 31, 2007 maybe this can help http://www.webmasterworld.com/forum88/9053.htm Quote Link to comment Share on other sites More sharing options...
Asperon Posted July 31, 2007 Share Posted July 31, 2007 or you can have it open in a new page completely and have javascript close that browse window ie. window.close(); Quote Link to comment Share on other sites More sharing options...
weemikey Posted July 31, 2007 Author Share Posted July 31, 2007 Thanks again. The problem (among many) is that I set all the SESSION vars for the user if the login is good, so if I close the browser and reopen another I'm not sure that the session would be there still. And the link you posted was good, but still is about using href. I need to use the header function, or I need to think about a totally different solution. Quote Link to comment Share on other sites More sharing options...
Asperon Posted July 31, 2007 Share Posted July 31, 2007 I forgot about sessions yeh that sucks... I don't think the header can do it, you might need to put the login outside the iframe..do you have alink I can look at? Quote Link to comment Share on other sites More sharing options...
Asperon Posted July 31, 2007 Share Posted July 31, 2007 could you possibly have the log submit send to the _parent ie. <form target="_parent" action="check_login.php"> and have that check_login.php check the login info if it is good then do a header() because you are already out of the iframe and if its not good then give them some text and tell them to go "<a href='javascript:history.back()'>back</a>" and try again..and going back will put them back at the login with the iframe Quote Link to comment Share on other sites More sharing options...
weemikey Posted July 31, 2007 Author Share Posted July 31, 2007 So I solved my own problem by working around it. I just made the login page it's own php/html page, not embedded in an iframe. That way when it redirects it just has to call index.php and not worry about the iframe stuff. Works like a charm. Sometimes just writing stuff down helps me think of a solution. Thanks again! Quote Link to comment 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.