laado Posted June 7, 2009 Share Posted June 7, 2009 is there any way to create password protected page? if yes then how? Link to comment Share on other sites More sharing options...
smerny Posted June 7, 2009 Share Posted June 7, 2009 if you don't care about setting sessions you can just have a php form with method=post and action=passwordprotectedpage.php .... then on that page you can get the values from the form and see if they match up with whatever you want them too.... if you are only using a password.. can be something like this for example<?phpif($_POST['password'] == "mypassword"){?> This is information that will be shown if the correct password was submitted<?php}else{ echo "Password is incorrect.";}?> Link to comment Share on other sites More sharing options...
laado Posted June 7, 2009 Author Share Posted June 7, 2009 can you explain it further?? if you don't care about setting sessions you can just have a php form with method=post and action=passwordprotectedpage.php .... then on that page you can get the values from the form and see if they match up with whatever you want them too.... if you are only using a password.. can be something like this for example<?phpif($_POST['password'] == "mypassword"){?> This is information that will be shown if the correct password was submitted<?php}else{ echo "Password is incorrect.";}?> Link to comment Share on other sites More sharing options...
smerny Posted June 7, 2009 Share Posted June 7, 2009 yourpage.php <html><head><title></title></head><body><?phpif($_POST['password'] == "mypassword"){?>This is information that will be shown if the correct password was submitted<?php}else{?><form action='yourpage.php' method='post'>Password: <input type='password' name='password'><br /><input type='submit' value='Submit'></form><?php}?></body></html> Link to comment Share on other sites More sharing options...
thescientist Posted June 14, 2009 Share Posted June 14, 2009 in and if/else PHP statement, what code would you put in if you wanted the person to be redirected to a page based on whether or not the provided the right information/password?nm, a simple google search did it for me. Link to comment Share on other sites More sharing options...
skaterdav85 Posted June 16, 2009 Share Posted June 16, 2009 You could also use HTTP authentication, which uses the $_SERVER superglobal....and you dont need to create a login page. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.