My modal is not showing up after I add header(location: homepage.php)
but modal is working fine if I remove the header
. How can I possibly do it? I've also tried using echo for alert and same thing happens, so I don't know what is wrong with my code. I hope someone can help me thank you!. Here is my code
login.php
if(isset($_POST['submit']))
{
$email = $_POST['email'];
$password = $_POST['password'];
$object = new Login();
$object->getCredentials($email, $password);
}
?>
<form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]); ?>" method="POST">
<div>
<label><b>EMAIL ADDRESS</b></label>
<input type="email" name="email" placeholder="Email"></input>
</div>
<div>
<label><b>PASSWORD</b></label>
<input type="password" name="password" placeholder="Password"></input>
</div>
<button type="submit" id="submit" name="submit">Login</button>
</form>
processlogin.php
<?php
include_once 'db.php';
class Login
{
public function getCredentials($email, $password)
{
$email = $email;
$password = $password;
$object = new Db();
$stmt = $object->connect()->prepare("SELECT * FROM user WHERE email=?");
$stmt->execute([$email]);
$stmtFetch = $stmt->fetch();
if($stmt->rowCount()==1 && $stmtFetch['email'] == $email && $stmtFetch['password'] == $password)
{
echo "<script>$('#loginsuccess').modal('show')</script>";
header("location: homepage.php");
}
}
}