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.
|
|
|
|
|
![]() |
||
password protect a page
|
||
| Notices |
![]() |
|
|
LinkBack | Thread Tools |
|
#1
|
|||
|
|||
|
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> |
|
|
|
#2
|
||||
|
||||
|
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 |
|
#3
|
|||
|
|||
|
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!! |
|
#4
|
||||
|
||||
|
Re: password protect a page
|
![]() |
| Tags |
| password, protect, page |
| Thread Tools | |
|
|
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 |