Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Thread: Email protected pages

  1. #1
    Join Date
    Mar 2007
    Posts
    68
    Thanks
    11
    Thanked 0 Times in 0 Posts

    Default Email protected pages

    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

  2. #2
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    Code:
    <?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>
    Last edited by Nile; 02-04-2008 at 04:19 AM.
    Jeremy | jfein.net

  3. #3
    Join Date
    Mar 2007
    Posts
    68
    Thanks
    11
    Thanked 0 Times in 0 Posts

    Default

    >>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

  4. #4
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    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?
    Jeremy | jfein.net

  5. #5
    Join Date
    Mar 2007
    Posts
    68
    Thanks
    11
    Thanked 0 Times in 0 Posts

    Default

    >>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

  6. #6
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    Ok, put this in the head part of your document:
    Code:
    <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>
    Jeremy | jfein.net

  7. #7
    Join Date
    Mar 2007
    Posts
    68
    Thanks
    11
    Thanked 0 Times in 0 Posts

    Default

    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

  8. #8
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    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.
    Jeremy | jfein.net

  9. #9
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    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.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  10. #10
    Join Date
    Mar 2007
    Posts
    68
    Thanks
    11
    Thanked 0 Times in 0 Posts

    Default

    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

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •