Log in

View Full Version : Password To Enter site and remain on site script



Markxxx
03-29-2007, 05:00 AM
Ok I am just wondering how hard would this be to do.

Here's what I am looking to do. I set up a webpage for a friend who has an online resume. You go to www.example.com and it would go right to her page.

Obviously anyone could see the resume. What I wanted to do was assign a single password to the page www.example.com lands at. It would be the same password given to everyone. No need to create users or passwords. Then that user woud enter the password and be able to view any of the pages on that site.

I thought about doing it with javascript cookie. The cookie could check against the password entered and give a session cookie. Each page in the resume would check that the session cookie was valid, if so then let that person view that page on the website.

Now of course the drawback is the password is on the source code with javascript.

I was told to use PHP, but I am unfamiliar with PHP, the only time I've used it was to email a form someone fills out to me.

I was going to go check out some books on PHP but would what I am looking to do be very complicated? So before I start looking around how hard would this be to do from scratch.

I don't want to spend weeks working on something that I would need to take a regular course on. I have enough trouble getting my cookies to work right :o)

Thanks

kosi
03-29-2007, 06:19 AM
It wouldn't be hard at all, actually. Declare a variable called $password or whatever you want to call it. Draw up an html form that asks for the password. (Use method=post in the html form.) The user's input will become a variable with whatever name you gave it in the html form. So if you called it something like "user_input", then do an if() construct kind of like in javascript:

if ($_POST["user_input"] == $password) {
echo("my dear friend's resume");
} else {
do something else;
}

That's the simple version, because it looks like you really want to look this up for yourself. But yeah, to answer your question, it's pretty straight forward.

codeexploiter
03-29-2007, 06:31 AM
You can consider this script (http://www.zubrag.com/scripts/password-protect.php)