jsmith664732 Posted September 28, 2013 Share Posted September 28, 2013 Hi, I am trying to set up a PIN protected area of my website. What I mean by that would be a simple pop up window similar to the usual php authentication pop-up window by most browser however where only a password is necessary to access the website - no username required. Would any of you know if this will be possible to do in php or any other language? Thank you. John Quote Link to comment https://forums.phpfreaks.com/topic/282507-new-form-authentication-pin-only-no-uername/ Share on other sites More sharing options...
trq Posted September 28, 2013 Share Posted September 28, 2013 Of course its possible. Quote Link to comment https://forums.phpfreaks.com/topic/282507-new-form-authentication-pin-only-no-uername/#findComment-1451598 Share on other sites More sharing options...
jsmith664732 Posted September 28, 2013 Author Share Posted September 28, 2013 Hi trq, would you be able to direct me somewhere to get the info to di it cos if I do the stuff below, I would only get a user/password window. thank you <?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 { ?> <p>This is the protected page. Your private content goes here.</p> <?php } ?> Quote Link to comment https://forums.phpfreaks.com/topic/282507-new-form-authentication-pin-only-no-uername/#findComment-1451602 Share on other sites More sharing options...
Ch0cu3r Posted September 28, 2013 Share Posted September 28, 2013 Modify the HTML form, delete the password field, rename the username field to pin then you can retrieve the entered value using $_POST['pin'] Quote Link to comment https://forums.phpfreaks.com/topic/282507-new-form-authentication-pin-only-no-uername/#findComment-1451607 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.