Quantcast
Channel: Active questions tagged html - Stack Overflow
Viewing all articles
Browse latest Browse all 74793

Why is this php-script always returns "True" html/php [duplicate]

$
0
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>

Viewing all articles
Browse latest Browse all 74793

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>