hungryOrb Posted October 11, 2007 Share Posted October 11, 2007 Hiya, I'd simply like a page which is protected by a password. Anyone know how to require a password input and if wrong do nothing? I fear this is JAVA right? Quote Link to comment https://forums.phpfreaks.com/topic/72748-passworded-page/ Share on other sites More sharing options...
Lukela Posted October 11, 2007 Share Posted October 11, 2007 Well what you can do is you could if the page. You can have two files, one with the ifs and one with the entire page you want to protect. Than if the inputted password matches yours than it includes the file you are protecting. if (isset($_GET['password'])) { echo "You are not able to access this page"; } elseif ($_GET['password'] != $yourpassword) { echo "Incorrect password"; } else { $password = 1; include_once "filelocation"; } than on that actual page you are protecting you can have if ($password != 1) { echo "Please login"; //or whatever } else { ?> Entire Page Code // Put your Entire Page code here <?php } ?> There are many ways to do it better than this... I'm still learning myself as well. Quote Link to comment https://forums.phpfreaks.com/topic/72748-passworded-page/#findComment-366904 Share on other sites More sharing options...
hungryOrb Posted October 11, 2007 Author Share Posted October 11, 2007 Thats using a form with an input for the password ye? Do you know how a prompt box could be used instead? If the value from a prompt box can be inserted onto the end of the link ie: control.php?id=" <| INSERT HERE |> " That would be cooL! If using an <a> tag, can display a prompt and then, hm , not sure :/ Quote Link to comment https://forums.phpfreaks.com/topic/72748-passworded-page/#findComment-366941 Share on other sites More sharing options...
otuatail Posted October 11, 2007 Share Posted October 11, 2007 What I do is have a login page followed by a PHP verify page. On failure go back to logon page. If Ok set a session variable and redirect to home page. All pages check for session variable. if not there then re-direct to login. nobody can look at any page unless first loged on. Desmond. Quote Link to comment https://forums.phpfreaks.com/topic/72748-passworded-page/#findComment-366999 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.