0

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>
Funk Forty Niner
  • 74,450
  • 15
  • 68
  • 141
fuux
  • 1
  • 1

0 Answers0