944,171 Members | Top Members by Rank

Ad:
Jul 12th, 2007
0

Password protect code

Expand Post »
I got this script from JavaScript Kit.com. The script refers to entering a userid and password to access one page. I have multiple acquaintances with each getting their own userid and password (it doesn't matter that it isn't encrypted). I am making one page that has the script on it. I would like to modify the code to receive various userid/password combinations to access respective pages.

The original code:

<script language="javascript">
<!--//
/*This Script allows people to enter by using a form that asks for a
UserID and Password*/
function pasuser(form) {
if (form.id.value=="JavaScript") {
if (form.pass.value=="Kit") {
location="page2.html"
}

I wonder if all I need to do is add a couple lines:
<script language="javascript">
<!--//
/*This Script allows people to enter by using a form that asks for a
UserID and Password*/
function pasuser(form) {
if (form.id.value=="JavaScript") {
if (form.pass.value=="Kit") {
location="page2.html"
} if(form.id.value=="example1") {
if (form.pass.value=="pass1") {
location="page3.html"
} if(form.id.value=="example2") {
if (form.pass.value=="pass2") {
location="page4.html"
}


Am I going in the right direction?
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
jeremiah sky is offline Offline
1 posts
since Jul 2007
Jul 12th, 2007
1

Re: Password protect code

Never ever use javascript top password protect pages. Getting around it is as easy as turning javascript off or just viewing the source code. Use server side password protect like Basic Authentication through .htaccess or a server side programming language like PHP.
Last edited by stymiee; Jul 12th, 2007 at 11:45 pm.
Moderator
Reputation Points: 161
Solved Threads: 38
He's No Good To Me Dead
stymiee is offline Offline
1,422 posts
since May 2006
Jul 13th, 2007
0

Re: Password protect code

They said encryption was not an issue. So just to answer the question, yes, you are going in the right direction. Just check on those braces if it is not working correctly.
Reputation Points: 85
Solved Threads: 64
Practically a Master Poster
sillyboy is offline Offline
686 posts
since Mar 2007
Jul 13th, 2007
0

Re: Password protect code

Encryption or not you can still unencrypt it or turn javascript off to defeat it. JavaScript password protection is always a bad idea.
Moderator
Reputation Points: 161
Solved Threads: 38
He's No Good To Me Dead
stymiee is offline Offline
1,422 posts
since May 2006
Jul 14th, 2007
0

Re: Password protect code

I am not disputing that fact.
Reputation Points: 85
Solved Threads: 64
Practically a Master Poster
sillyboy is offline Offline
686 posts
since Mar 2007
Aug 20th, 2007
0

Re: Password protect code

you have any idea where i learn PHP first time?
I have only HTML idea
Reputation Points: 10
Solved Threads: 0
Newbie Poster
jishu is offline Offline
3 posts
since Aug 2007
Aug 20th, 2007
0

Re: Password protect code

Start with http://www.php.net
Moderator
Reputation Points: 161
Solved Threads: 38
He's No Good To Me Dead
stymiee is offline Offline
1,422 posts
since May 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in JavaScript / DHTML / AJAX Forum Timeline: How to make selected index zero for dropdown list box in java script..?
Next Thread in JavaScript / DHTML / AJAX Forum Timeline: How do I set linked Office files to open with full toolbar functionality?





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC