Google Answers Logo
View Question
 
Q: Conditional link. ( Answered 5 out of 5 stars,   1 Comment )
Question  
Subject: Conditional link.
Category: Computers > Programming
Asked by: just4fun2-ga
List Price: $20.00
Posted: 22 Jun 2004 13:10 PDT
Expires: 22 Jul 2004 13:10 PDT
Question ID: 364680
Hi, I am using Frontpage 2003, with Frontpage Extensions turned OFF.  

I would like to split my web site in half.  The second half is
accessed by a simple link, but this link is conditional.  The
condition would be a simple password.  If you know the password -
you're in.

Here is how it would work, a page is loaded, the two items on the page
would be the password field and then below the password is the link to
the second half of the website.

Example: 

Password: ______________ (enter in password)

(Link)

If the password entered is incorrect the page would reload when the
link is pressed. If password is correct then the second half of my
website would load.

Please make it simple - I'm new to this website stuff... :)
 
Thank you for your time!

Request for Question Clarification by larre-ga on 22 Jun 2004 13:46 PDT
This process generally requires a javascript, or other coding such as
Perl or PHP. It cannot be accomplished via HTML, unless you simply
give out the "password coded" link. You can do something quite
similar, using a password protected directory, using browser protocol
to allow entry.

I can explain several ways to accomplish what you're after, but it
will require some steps beyond HTML. Are you interested in pursuing
that type of solution?

Request for Question Clarification by larre-ga on 22 Jun 2004 14:10 PDT
I have located an excellent javascript that is very easy to add to
your webpage, and does exactly what you wish it to do. I am writing
simplified instructions, and creating an example, so you can see how
it works. I will post the completed Answer shortly.

---l

Clarification of Question by just4fun2-ga on 22 Jun 2004 14:17 PDT
Hi, thank you for taking the time to help me.

I was thinking that javascript or Jscript would be the best given my
depth of knowledge.  I would rather not use server side coding at this
point.

I hope this clarification is helpful.

Thanks.
Answer  
Subject: Re: Conditional link.
Answered By: larre-ga on 22 Jun 2004 16:47 PDT
Rated:5 out of 5 stars
 
Greetings, just4fun2!

Your Clarification was helpful, thanks. It confirmed that you are
willing to work with a little javascript to accomplish your goal.

I've selected a password protection javascript that is considered to
be one of the best available. Any javascript can be defeated, of
course, but "Password Protection - Login Coder" goes a long way toward
making portions of your website available only to those who possess
the correct password.

This Login Coder script is a bit more than the link that you list as
the method of moving into the protected section of the site. This
script uses a form select and a form button, rather than a link, but
is easily understood on the web page, and easily used, all the same.
When we borrow coding from others, sometimes appearance is slightly
compromised. The script is very carefully written to obsfucate
information from the casual user. I don't wish to negate this
protection by changing form elements into simple hidden input fields.

The script is available from the JavascriptSource at Internet.com"

http://javascript.internet.com/passwords/login-coder.html 

Instructions on the page (in the textbox) read, in part:

"Create your users, their passwords, and their destination pages using
the form above.

*Honestly, we don't even totally understand this JavaScript!*"

The form they're speaking of shows a list of four users on the left
side. You'll want to highlight each name and press (click) the Delete
User Button. Once all names are deleted, and the left-hand box is
empty, you'll fill in the form to create your site protection
password.

User: Member
Password: xxxxxxxx (your choice, exactly 8 letters (a-z))
Page Name: xxxxxxxx (your choice - the page your members will be
                     directed to, but its name must have 8 letters)


Once you've entered your choices, select (click) New User. A
javascript textbox will appear asking for a User Name. Member, or any
other generic name will work best.

Now press (click) the Update/Show Coding button. 

Your personalized code will be displayed in the large textbox.
Right-click, choose Select All, right-click again, and choose Copy.

You'll Paste the code into the proper spot in your HTML document. I
also recommend opening up a blank document (in Notepad) and saving the
script, as is.

Several lines can be changed to make the script more intuitive for use
with "one password for all". I'll show an example here, but you'll
want to make your changes to -your- copy of the script, rather than
cut and paste my changes. [ and ] are used in place of < and > so that
it will display properly in this answer.

In the script, eliminate the following line:

  [ option value = [ 'x' ]

This will insure that only the single line shows in the input box. 

You can change the "Member-Only Area!" to anything you might prefer.
You can eliminate the word Username (just erase) if you think that
might be too confusing.

In this line:

type = button value = "Login"

You can change the value to any words you prefer. 

Eliminate the following lines/sections from the script:

 alert ( "Please Select Your Name From The List" );
 return;

and

 if ( h1 ! = params [ 1] ) {
 alert ( "Incorrect Password!" ) ;  return; };


Once you've placed the script where you like it on the page, and saved
the page, simply upload the file again.

Make sure the page you wish to redirect to is named exactly as you
specified in the Upload Coder -- an 8 letter name. If you selected the
page name members1, the actual page should be named members1.html.


Here is a sample of the script, with the changes I've outlined above.
The password is: okeydoke  - the password protected page is named
hideit4u.html.

http://68.15.21.151/uploads/researchers/hideit4u.html


Search Strategy
----------------------------------------------------------------------

Google Search Terms

javascript password protection

I hope this solution meets your requirements. If anything is unclear,
or if you need further instructions, or have questions about the
script or the solution, please, feel free to ask for Clarification and
I will be happy to assist you further.

---larre

Clarification of Answer by larre-ga on 22 Jun 2004 17:11 PDT
My apologies... 

The Sample page itself is:

http://68.15.21.151/uploads/researchers/passwordprotect.html

---l

Request for Answer Clarification by just4fun2-ga on 23 Jun 2004 10:25 PDT
Hi, thank you for your research and help.  I do have two questions,
does the website you are directing me to generate the code I need?  Is
the code extremely complex ONLY to defeat someone who would like to
break it?

I'll be giving you five ***** stars once I figure out how to do that! :)

Thanks again.

Clarification of Answer by larre-ga on 23 Jun 2004 10:43 PDT
The website with the code generator is:

http://javascript.internet.com/passwords/login-coder.html

After you've deleted the sample names, and added your own member name
(or names) using the code generator, the ready-to-go code will be
displayed in the multiple-line textbox just below the code generator
buttons. The code will work just as is. The enhancements I suggested
affect appearance only. You can make the changes now, or later. Or not
at all.


This code is relatively complex, because it needs to be in order to
protect against common methods of defeating javascript password
protection. These methods have become so well known, that even
relatively casual computer users have learned to bypass them. The
program I'm recommending is sufficiently difficult to decipher unless
the user has a better than average grasp of javascript. This "class"
or "type" of javascript uses the password itself to determine location
of the redirect link. This particular script encrypts that password
more robustly, protecting it from casual misuse.

---larre

Request for Answer Clarification by just4fun2-ga on 23 Jun 2004 11:39 PDT
Hi, When I go to the site you built using the link:

http://68.15.21.151/uploads/researchers/passwordprotect.html

I get:  A runtime error has occurred.  Do you wish do debug?  Line 44 Syntax error.

When I type in okeydoke I get the same error message only it's line 15.

Is it me or something about the code?

Thank you

Request for Answer Clarification by just4fun2-ga on 23 Jun 2004 11:50 PDT
I'm sorry.  It appear to be something in IE which I have fixed.  

I did have a minor problem, when I type in okeydoke and click, I am
not redirected to hideit4u.html

Thanks you again for your help!

Clarification of Answer by larre-ga on 23 Jun 2004 12:13 PDT
My apologies. Give it another try. 

The Coder -only- allows characters for all names. No numbers. I used a
number in the naming of the hidden file, which the script encoder
changed to the letter "z". I have changed the name of the "hidden"
page, and the script works correctly. I'd initially tested on my own
system, then went through the process again, using the Code Generator
to make another copy of the script, choosing fancier names for a
sample. The hidden page the cript was actually seeking was named
"hideitzu.html". Going, with the flow <grin>, I re-uploaded a page
with that name to correct the problem.  I've re-tested with several
different browsers to make sure it works correctly.

---l

Request for Answer Clarification by just4fun2-ga on 23 Jun 2004 12:51 PDT
You're goin' hate this...  

http://68.15.21.151/uploads/researchers/passwordprotect.html

I still was unable to be forwarded to the new page.  Passwork okeydoke

Like I said, you're goin' hate it.  :)

Clarification of Answer by larre-ga on 23 Jun 2004 13:04 PDT
Naaaah! I don't hate it. I actually think it's probably a cache issue.
If you manually clear your cache (Tools > Internet Options > Delete
Files (Button) > OK), then force a page refresh (right-click and
select Reload), it will probably work for you. Beyond that, it might
be your Browser javascript settings, firewall settings, or pop-up
blocker settings.

---l
just4fun2-ga rated this answer:5 out of 5 stars and gave an additional tip of: $10.00
Get job - well written - quick responses.

Comments  
Subject: Re: Conditional link.
From: larre-ga on 23 Jun 2004 13:05 PDT
 
Thank you very much for the rating and tip!

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy