Simple Access Control
To protect a page, you need to insert PHP code similar to the following at the top of your page:
?>
<HTML>
...Rest of page goes here...
It's very important that the code appears in your page before any HTML.
The realm
parameter contains the name used to describe the
pages being protected. If you want to protect several pages using the
same set of passwords, they should all be in the same Realm.
The errorMessage
parameter contains a message that is displayed
to the user if their login fails.
The example above sets up two users, the user guest
has
the password secret
and the user anybody
has
the password PassWord
. You should, of course, tailor the
list of usernames and passwords as appropriate. Note that usernames and
passwords are case-sensitive.
To see how this works in practice, here is
a page that has been protected using the above code. Try it and see -
remember, you can log in as guest
or anybody
using the passwords described above.
- Simple Access Control
- Using an External Authentication Source