如何从iframe弹出窗口重定向父页面?

时间:2016-03-26 10:43:18

标签: php

所以我有一个页面,当用户点击登录按钮时,它将打开一个带有登录表单的iframe弹出窗口。因此,如果用户提交了正确的用户名/密码,它将重定向父页面,让我们说Main.php。但是,我无法实现这一点,因为它继续在iframe弹出窗口中重定向它。我该如何实现这一目标?我对php很新,所以请澄清你的答案。

这是处理登录的代码段。告诉我你是否需要更多。谢谢。

<?php
include '../Initialization.php';

if (empty ($_POST) === false) {

    $username = $_POST ['username'];
    $password = $_POST ['password'];

    if (empty ($username) === true || empty ($password) === true) {
        $errors[] = 'You need to enter a username and password!';
    } else if (user_exists ($username) === false) {
        $errors[] = 'We can\'t find the username you entered. Have you registered?';
    } else if (user_active ($username) === false) {
        $errors[] = 'You haven\'t activated your account!';
    } else {
        $login = login($username, $password);
        if ($login === false) {
            $errors[] = 'That username/password combination is incorrect!';
        } else {
            $_SESSION['user_id'] = $login;
            header("Refresh:0; url=../../Main.php"); //Am I doing anything wrong here? 
            exit();
        }
    }

    print_r ($errors);
}
?>

将打开iframe的链接:

<a class='iframe' href="Login.php" style="text-decoration:none; color:#FFF">LET'S GO</a

登录表单:

    <form action = "Core/System/LoginProcess.php" method="post">
      <p>
        <input name="username" type="text" class="textBox" id="username2" placeholder = "Username" onblur="this.value=removeSpaces(this.value);"/>
          <br />
          <br />
        <input name="password" type="password" class="textBox" id="password" placeholder = "Password" />
</p>
      <p>&nbsp;</p>
      <p>
        <input name="Login" type="submit" class="loginButton" id="Login" value="Login" />
      </p>
      </form>

0 个答案:

没有答案