When I get into my sign in page it displays the error:
> Fatal error: Uncaught Error: Call to a member function fetch() on bool
> in C:\xampp\htdocs\SUPINFO\Page0\index.php:43 Stack trace: #0 {main}
> thrown in C:\xampp\htdocs\SUPINFO\Page0\index.php on line 43
I don't know why this is happening Here is the code that is causing the error (my index.php page):
<form action="index.php" method="POST">
<div class="textbox1">
<i class="fa fa-user"></i>
<input type="text" placeholder="ID" name="ID" value="" required/>
</div>
<div class="textbox1">
<i class="fa fa-lock"></i>
<input type="password" placeholder="Password" name="password" value="" required/>
</div>
<div id="submit">
<input type="submit" name ="" value="login">
</div>
</form>
<?php
try
{
$bdd = new PDO('mysql:host=localhost;dbname=hps;charset=utf8', 'root', '');
}
catch(Exception $e)
{
die('Erreur : '.$e->getMessage());
}
?>
<?php
$id =$_POST['ID'];
$mdp = $_POST['password'];
$reponse0 = $bdd->query("SELECT*FROM clients WHERE id_pass='$id'");
$validation = $reponse0 -> fetch();
if ($validation['id_pass'] == $id && password_verify($mdp, $validation['password']) )
{
?>
<script type="text/javascript">
window.open("../Page1/index.php");
</script>
<?php
}
else{
?>
<script type="text/javascript">
setTimeout(function(){window.alert("Password or ID is incorrect")},200);
</script>
<?php
}
?>