Log in

View Full Version : Email protected pages



Benedizione
02-03-2008, 04:16 PM
I have been looking for an unusual script. There are scripts available to "password" protect a website page meaning that a person cannot view the page without entering the appropriate password into the prompt.

Well, I am wondering if I can create a script that will "EMAIL ADDRESS" protect a website page meaning that a prompt will come up asking for a particular email address.............NO password.

Is this possible?

Dre

Nile
02-03-2008, 04:37 PM
<?php

function httpauth(){
header('WWW-Authenticate: Basic realm="My SITE!"');
header('HTTP/1.0 401 Unauthorized');
echo 'You cancled';
exit;
}

while($_SERVER['PHP_AUTH_USER'] != 'email@email.com' || != 'email1@email.com' || != 'email@email2.com'){
httpauth();
}
?>
<html>
<head>
<title>Title</title>
</head>
<body>
</body>
</html>

Benedizione
02-03-2008, 05:43 PM
>>Like you want a promt that will come up and ask for a email adress and then you put all the email adresses in an array?<<

What do you mean by "array"?

The purpose of fixing a particular website page with an email prompt is so that only certain people can access the page. I have people from all over the world who are finding a particular page on my site via google and so I want to email protect only "one page" out of the entire website.

I want to keep information on that particular page as private as possible.

I can run a test page of your script and see if it helps me to understand better what you are showing me but I am not sure what you mean by an "array."

Dre

Nile
02-03-2008, 05:47 PM
So you want a script that will ask for an email address? Yo want a numerous amount of email addresses to be allowed r only one email address?

Benedizione
02-03-2008, 06:32 PM
>>So you want a script that will ask for an email address? Yo want a numerous amount of email addresses to be allowed r only one email address?<<


Yes.

And, actually one email address will do.

Dre

Nile
02-03-2008, 06:35 PM
Ok, put this in the head part of your document:

<SCRIPT language="JavaScript">
<!--hidevar password;
var emailm="PASSWORD GOES HERE";
email=prompt('Enter the email adress!',' ');
if(email==emailm)
alert('You can now see the page!');
else {
window.location="url of page if answered wrong";
}//--></SCRIPT>

Benedizione
02-03-2008, 10:44 PM
Nile,

Thank you for that coding! I will try that out.

I decided that I want to play with something else too on that one particular page of my site. How can I set up the prompt similiar to a password protected page? However, I want to write a message in that prompt which requires a correct answer in order to view the page. And, for those who try to access the page and do not get the answer right because they do not have access to the page, will receive a prompt reply of "You do not have access to this page of the site, please go to .............."

For instance, a prompt comes up and says "What is your favorite color?" Maybe the passcode protected page code is the same as what I am wanting? Or can I tweak the last code you gave me to insert a message in that prompt?

Dre

Nile
02-03-2008, 10:47 PM
Yes you will find the code that I posted is very easy to edit, so play around with it and it'll answer all of your questions.

djr33
02-03-2008, 11:03 PM
This really isn't special at all, I don't think-- just use any old password script (not that the one above won't work) and replace the "password" with an "email", and you're done.

Benedizione
02-03-2008, 11:13 PM
I just tried it though and the prompt is coming up but it is not securing anything. The prompt is not asking for an answer. I just get the prompt, the only option is to select "ok" and then it takes me directly to the page. What am I doing wrong?

Dre

Benedizione
02-04-2008, 04:08 AM
But how do I find a script where the passcode cannot be viewed in the script on the page?

People who are familiar with creating webpages would easily find the answer by viewing the source code of the page. Every script I see gives away the answer.

Nile
02-04-2008, 04:20 AM
<?php

function httpauth(){
header('WWW-Authenticate: Basic realm="My SITE!"');
header('HTTP/1.0 401 Unauthorized');
echo 'You cancled';
exit;
}

while($_SERVER['PHP_AUTH_USER'] != 'email@email.com' || != 'email1@email.com' || != 'email@email2.com'){
httpauth();
}
?>
<html>
<head>
<title>Title</title>
</head>
<body>
</body>
</html>

This my friend would use php, like I said before^^.

thetestingsite
02-04-2008, 04:49 AM
This my friend would use php, like I said before

That is assuming that your hosting server supports php.