Jump to content

[SOLVED] I'm sorry, another (easier!) iframe question


weemikey

Recommended Posts

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!

Link to comment
Share on other sites

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>

Link to comment
Share on other sites

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>

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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!

Link to comment
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.