Jump to content

Password Protected Page


laado
 Share

Recommended Posts

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

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

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

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.

Edited by thescientist
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...