Hello again. So I googled myself into finding this code:
Now, I thought I was pretty clever, until I tried it. It gives me a nice little password form, but it also displays the page content right along with it. And then, just for kicks and giggles, when I went ahead and entered the username and password I assigned, it took all of the supposedly protected content away and breaks my page apart. Kind of backwards, no?
Does it matter that there is php in the protected content?
<sigh>
Code:
<?php // Define your username and password $username = "someuser"; $password = "somepassword"; if ($_POST['txtUsername'] != $username || $_POST['txtPassword'] != $password) { ?> <h1>Login</h1> <form name="form" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <p><label for="txtUsername">Username:</label> <br /><input type="text" title="Enter your Username" name="txtUsername" /></p> <p><label for="txtpassword">Password:</label> <br /><input type="password" title="Enter your password" name="txtPassword" /></p> <p><input type="submit" name="Submit" value="Login" /></p> </form> <?php } else { ?> // put password protected content here <?php } ?>
Does it matter that there is php in the protected content?
<sigh>
Comment