用户登录后,将出现一个弹出窗口,显示index.php。但是,具有login.php的原始浏览器更改为authenticate.php。 如何完全关闭以前的浏览器?
<?php
session_start();
require_once './config/config.php';
if ($_SERVER['REQUEST_METHOD'] === 'POST')
{
$username = filter_input(INPUT_POST, 'username');
$passwd = filter_input(INPUT_POST, 'passwd');
$remember = filter_input(INPUT_POST, 'remember');
$passwd= md5($passwd);
//Get DB instance. function is defined in config.php
$db = getDbInstance();
$db->where ("user_name", $username);
$db->where ("passwd", $passwd);
$row = $db->get('admin_accounts');
if ($db->count >= 1) {
$_SESSION['user_name'] = $username;
$_SESSION['user_logged_in'] = TRUE;
$_SESSION['admin_type'] = htmlentities ($row[0]['admin_type']);
$_SESSION['first_name'] = htmlentities ($row[0]['first_name']);
$_SESSION['last_name'] = htmlentities ($row[0]['last_name']);
$_SESSION['position'] = htmlentities ($row[0]['position']);
if($remember)
{
setcookie('username',$username , time() + (86400 * 90), "/");
setcookie('password',$passwd , time() + (86400 * 90), "/");
}
echo "<script>window.open('http://localhost/index', '_blank', 'toolbar=0,location=0,menubar=0');</script>";
exit;
} else {
$_SESSION['login_failure'] = "Invalid username or password";
header('Location:login');
exit;
}
}
这是打开弹出窗口的代码的一部分:
echo "<script>window.open('http://localhost/index', '_blank', 'toolbar=0,location=0,menubar=0');</script>";
我已经尝试使用window.close();
echo "<script>window.close(); window.open('http://localhost/index', '_blank', 'toolbar=0,location=0,menubar=0');</script>";