Ive tried getting this to work for an hour now, but every time the if-statement returns as false. When I change count to "count == 0" it works, but otherwise I am not able to get it to work. :/
<?php
$database = "passwords";
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$passord = test_input($conn,$database,$_POST["passord"]);
$sql = "SELECT id FROM passwords WHERE passord = '$passord'";
$result = mysqli_query($conn,$database,$sql);
$count = mysqli_num_rows($result);
echo('<script>console.log("connected successfully");</script>');
if($count == 1) {
header("location: stemmegivning.php");
}
else {
echo '<script type="text/javascript">wrongPw ()</script>';
}
}
function test_input($data) {
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}
?>