Submit Your Article Webforumz RegistrationAnnouncements Contact Webforumz StaffContact
Home Resources Blogs Meet the Team Contact Register
 

Go Back   WebForumz.com > The Code > JavaScript

Reply
 
LinkBack Thread Tools
Old March 7th, 2006, 04:47 PM   #1
Reputable Member
 

Join Date: Mar 2006
Location: UK
Posts: 119
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 snappy is on a distinguished road
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>
snappy is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old March 7th, 2006, 05:32 PM   #2
Reputable Member
 
craig's Avatar
 

Join Date: Sep 2005
Location: Preston, UK
Age: 23
Posts: 382
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 craig will become famous soon enough
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
craig is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old March 7th, 2006, 05:56 PM   #3
Reputable Member
 

Join Date: Mar 2006
Location: UK
Posts: 119
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 snappy is on a distinguished road
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!!
snappy is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old March 7th, 2006, 06:09 PM   #4
Highly Reputable Member
 
herkalees's Avatar
 

Join Date: Jul 2005
Location: Massachusetts, USA
Age: 89
Posts: 563
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 herkalees will become famous soon enough herkalees will become famous soon enough
Re: password protect a page

.htaccess is everyone's easy friend.
herkalees is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Bookmarks

Tags
password , protect , page


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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 Your Design and Layout 21 November 26th, 2007 04:51 AM
How to password encript a page acrikey HTML, XHTML and CSS 7 August 22nd, 2007 10:39 AM
password protecting just one page catalystmediastudios HTML, XHTML and CSS 2 March 30th, 2007 11:46 PM
Password protecting a page paddywhack HTML, XHTML and CSS 10 February 7th, 2007 03:13 PM
Looking for EASY password protect script Lchad PHP 3 January 27th, 2007 08:54 PM


Search Engine Optimization by vBSEO 3.2.0 RC8