I can't figure out why it is the function test() is allways returning True.
It should check if both inputs are equal to $benutzer
and $passwort
.
And only if true return "True"
.
Thanks in advance.
$user = $_POST["user"];
$pass = $_POST["pass"];
$benutzer = "admin";
$passwort = "admin";
if($_SERVER['REQUEST_METHOD'] == "POST" and isset($_POST['select'])) {
test();
}
function test() {
if (($benutzer == "$user") and ($passwort == "$pass")) {
echo "
<p>True</p>
";
}
else {
echo "
<p>False</p>
";
}
}
<div>
<form action="password.php" method="POST">
<input type="text" placeholder="Username" name="user">
<input type="password" placeholder="Password" name="pass">
<input type="submit" class="button" name="select" value="select" />
</form>
</div>
False
"; } }?>` Now it works! – Seth B Jan 11 '20 at 17:39