password protect a page

This is a discussion on "password protect a page" within the JavaScript Forum section. This forum, and the thread "password protect a page are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > JavaScript Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Mar 7th, 2006, 20:47
Up'n'Coming Member
Join Date: Mar 2006
Location: UK
Posts: 97
Thanks: 0
Thanked 0 Times in 0 Posts
password protect a page

I need to password protect some pages on my site and have tried using the following code.
It looks ok and works as a log-in, but keeps returning to the log-in page rather than the location I want.
Anyone feel like helping a CreativeNotTechie!?
<html>
<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=="wildlife") {
if (form.pass.value=="pandabear") {
location="page2.html"
} else {
alert("Invalid Password")
}
} else { alert("Invalid UserID")
}
}
//-->
</script>
<center>
<table bgcolor="white" cellpadding="12" border="1">
<tr><td colspan="2"><center><h1><i><b>Login
Area</b></i></h1></center></td></tr>
<tr><td><h1><i><b>UserID:</b></i></h1></td><td><form name="login"><input
name="id" type="text"></td></tr>
<tr><td><h1><i><b>Password:</b></i></h1></td><td><input name="pass"
type="password"></td></tr>
<tr><td><center><input type="button" value="Login"
onClick="pasuser(this.form)"></center></td><td><center><br><input
type="Reset"></form></td></tr></table></center>
</html>
Reply With Quote

  #2 (permalink)  
Old Mar 7th, 2006, 21:32
craig's Avatar
Reputable Member
Join Date: Sep 2005
Location: Preston, UK
Age: 21
Posts: 381
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to craig
Re: password protect a page

The login page isnt page2.html is it by any chance???
One more thing, you shouldnt be using Javascript to password protect a page, PHP is far more secure since you cant just click View Source and see the username and password!!!!
Only use it if there is nothing secure on the page2 section of the website.
One more thing, (i promise), you dont need this in a table, you should also style the font with CSS, there's a lot of messy code in what you've got there!

Craig
Reply With Quote
  #3 (permalink)  
Old Mar 7th, 2006, 21:56
Up'n'Coming Member
Join Date: Mar 2006
Location: UK
Posts: 97
Thanks: 0
Thanked 0 Times in 0 Posts
Re: password protect a page

Nope, page2.html was the test target page.
It works when user clicks submit, but not when user hits return...any clues?

Yup I agree about the font formatting, I was just looking at this in principle and trying to find a simpler way to password protect than php.

See what you mean about password being in source code. hmmm... Can I hide the source code in any way?

Is there another way of creating a password protect w/o hours of learning php??

Still CreativeNotTechie!!
Reply With Quote
  #4 (permalink)  
Old Mar 7th, 2006, 22:09
herkalees's Avatar
Highly Reputable Member
Join Date: Jul 2005
Location: Massachusetts, USA
Age: 87
Posts: 576
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to herkalees Send a message via MSN to herkalees Send a message via Yahoo to herkalees
Re: password protect a page

.htaccess is everyone's easy friend.
Reply With Quote
Reply

Tags
password, protect, page

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
password enabled page saadi babar Starting Out 21 Nov 26th, 2007 08:51
How to password encript a page acrikey Web Page Design 7 Aug 22nd, 2007 14:39
password protecting just one page catalystmediastudios Web Page Design 2 Mar 31st, 2007 03:46
Password protecting a page paddywhack Web Page Design 10 Feb 7th, 2007 19:13
Looking for EASY password protect script Lchad PHP Forum 3 Jan 28th, 2007 00:54


All times are GMT. The time now is 10:44.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43