I just want to ask why my header in PHP is not redirecting though all the statement is correct and functioning properly.
index.php:
<form action="php/Api/verifyUser.php" method="post">
username: <input type="text" name="username"><br>
password: <input type="text" name="password"><br>
<input type="submit">
</form>
php/Api/verifyUser.php:
<?php
include "../userDAO.php";
session_start();
//$content = file_get_contents("php://input");
//$json_data = json_decode($content, true);
$username = $_POST["username"];
$password = $_POST["password"];
$userDAO = new UserDAO();
$process = $userDAO->verifyUser($username, $password);
if($process["state"] == 1) {
echo "Successfully Log in!";
header("location : ../../homepage.php/");
} else {
echo "failed to Log in!";
header("location : ../../login.php");
}
?>
Note:
The userDAO instancess is working fine, state is "1" if authentication true.
Warning in verifyUser.php: The character encoding of the HTML document was not declared. The document will render with garbled text in some browser configurations if the document contains characters from outside the US-ASCII range. The character encoding of the page must be declared in the document or in the transfer protocol.
The code above will echo the "Successfully log in!" message the same with the failed message if the condition is false. But the header is not redirecting to its location? What seems to be the problem here? Thanks.