But what I want to happen, is if there is an error, then the error shows in the fancybox modal box. In order for the error to show I have to not specify a target in the form action. However, if login info is correct, then it redirects to the members page in the fancybox modal box. What I want is for the modal box to close and the user go to the page in the parent frame.
Does anyone know how I can achieve this?
This is how I am calling the login script:
<div id="esns-login-wrapper">
<p><a class="iframe" href="/login/">Login</a> / <a href='./?logout=1'>Logout</a></p>
<?php
if($input->get->logout == 1) {
$session->logout();
$session->redirect("/"); // start them on a fresh page, or redirect to another
}?>
</div>
This is what I am using for fancybox
$('a.iframe').fancybox({
maxWidth : 350,
maxHeight : 300,
fitToView : false,
width : '350',
height : '300',
autoSize : false,
closeClick : false,
openEffect : 'none',
closeEffect : 'none',
showCloseButton: false,
'type' : 'iframe',
padding: 0,
margin: 0,
scrolling: 'no',
showCloseButton: false
});
And this is what I am using for my login script:
<?php
// $out is where we'll keep our output
$out = '';
// $form is where we'll keep our custom login form
$form = "
<form action='./' method='post' id='login-form' >
<p><label>Username <input id='input-name' class='text-input required default' type='text' name='user' title='Login name'/></label></p>
<p><label>Password <input id='input-password' class='text-input required default' type='password' name='pass' title='Password'/></label></p>
<p><input type='submit' name='submit_login' value='Login' id='submit'/></p>
</form>";
if($user->isLoggedin()) {
// user is already logged in
if($input->get->logout) {
// page was accessed with ?logout=1 GET variable, so log them out
$session->logout();
$session->redirect('./');
} else {
// tell them they are logged in and how to logout
$out = "<p>You are logged in. <a href='./?logout=1'>Logout?</a></p>";
}
}
else if($input->post->user && $input->post->pass) {
// user submitted the login form
if($session->login($input->post->user, $input->post->pass)) {
// based on user roles where to redirect them
if($user->isSuperuser()) {
$session->redirect('./');
} else {
$session->redirect('/members/');
}
} else {
// the login failed
$out = "<p class='error'>Login failed. Try again.</p>";
$out .= $form;
}
}
else {
// user arrived at login page for first time
$out = $form;
}
echo $out;













