I won't write the code for you, but I'll give you the logic behind it. It's fairly simple.
create a table that contains your users.
allow the person a place to register
give the person a place to login.
Check that username/password against the database.
If they're in the database, they're a valid user.
Use an if statement to display the image to them if they were found in the database.
Cgraz