我将如何将此代码重定向到另一个php文件

时间:2018-12-24 19:37:31

标签: php redirect

我只是想知道登录后如何重定向此php文件到另一个php文件,而不是发出一条消息

ive尝试将成功更改为此标头('Location:index.php');但这似乎也不起作用,并且我也通过替换输出消息来尝试了此操作
if($_POST['username'] == $username && $_POST['password'] == $password)

header('Location:index.php'); ?> 但这似乎也没有帮助

$database = new Database();
$db = $database->getConnection();

// prepare user object
$user = new User($db);
// set ID property of user to be edited
$user->username = isset($_GET['username']) ? $_GET['username'] : die();
$user->password = base64_encode(isset($_GET['password']) ?     $_GET['password'] : die());
// read the details of user to be edited
$stmt = $user->login();
if($stmt->rowCount() > 0){
// get retrieved row
$row = $stmt->fetch(PDO::FETCH_ASSOC);
// create array
$user_arr=array(
    "status" => true,
    "message" => "Successfully Login!",
    "id" => $row['id'],
    "username" => $row['username']
);
}
else{
$user_arr=array(
    "status" => false,
    "message" => "Invalid Username or Password!",
);
}

在登录后能够重定向到index.php而不是输出消息

0 个答案:

没有答案