[英]how can i redirect page in php with echo or header?(in if condition)
好的,當密碼正確但頁面未重定向時,我嘗試了echo和header來重定向頁面。 我嘗試了幾次,但沒有任何反應
我在這個網站上使用xammp和php7。
if($stmt->rowCount() > 0){
// get retrieved row
$row = $stmt->fetch(PDO::FETCH_ASSOC);
// create array
$user_arr=array(
"status" => true,
"message" => "Successfully Login!",
header( 'Location: ./index.html' ),
"id" => $row['id'],
"username" => $row['username']
);
在phpstorm中,當我使用header('Location:./index.html')時,它告訴我我正在使用void。
問題是陣列損壞。
<?php
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']
);
// Moved out of $user_arr
header( 'Location: ./index.html' );
exit;
}
?>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.