Html help, Advanced Created 15 years ago2009-10-27 18:52:04 UTC by Unbreakable Unbreakable

Created 15 years ago2009-10-27 18:52:04 UTC by Unbreakable Unbreakable

Posted 15 years ago2009-10-27 19:02:38 UTC Post #274865
So I'm trying to create a password protect webpage in java script, This is what I got:

tdproject.html:

<html>
<head>
<script>
<!--- Hide from old browsers
function submitPass() {
var location;
var password;
password=this.document.login.password.value;
location=password + ".html";
location.href = location;
}
--->
</script>

</head>
<body>
<form name="login">
<INPUT TYPE="password" NAME="password" VALUE="" size="20">
<INPUT TYPE="button" NAME="button" Value="Submit Password" onClick="submitPassword(this.form)">
</form>
</html>

and in the same folder I have chaching.htm (so 'chaching' being my password)

So this kinda works...

I got to the html and put in the password (chaching) then hit submit.

it then takes me here:

http://mikeverret.webs.com/tdgame/tdproject.htm?password=chaching

and then thats it.

I tried putting this in the chaching.htm file;
<META HTTP-EQUIV="Refresh" content= "0;URL=http://www.blahblahblah.ca">

but that did not work.
If you don't know what I mean then try it:
http://mikeverret.webs.com/tdgame/tdproject.htm
password is 'chaching'

(password is a random thought up word)
Sos yes I want it to redirect to a page if the password is incorrect, and to another page if the password is correct.

I noticed this up top:
location.href = location;
instead of location, would I put another address?

edit : great now its not working ARGH!
Unbreakable UnbreakableWindows 7.9 Rating!
Posted 15 years ago2009-10-27 19:41:31 UTC Post #274869
This is the error I am getting from your password page:
User posted image
Posted 15 years ago2009-10-27 19:46:18 UTC Post #274870
hmmm, it works for me.. don't know.. what browser are you using?

here actually, try this:

http://mikeverret.ca/tdgame/tdproject.htm
Unbreakable UnbreakableWindows 7.9 Rating!
Posted 15 years ago2009-10-27 19:51:28 UTC Post #274871
Did you really just ask what browser he's using to get an internet explorer error message?

That said;
why the fuck are you using internet explorer.
Archie ArchieGoodbye Moonmen
Posted 15 years ago2009-10-27 19:53:16 UTC Post #274873
haha yeah, noticed it after.. lol
Unbreakable UnbreakableWindows 7.9 Rating!
Posted 15 years ago2009-10-27 20:08:01 UTC Post #274874
I tried your page with Internet Explorer, Firefox and Chrome. It does not work on all 3 browsers. Question: What is suppose to happen if somebody were to put the wrong password in? When I put a random word, I get nothing, no pop-up warning or re-direct page about inputting the wrong password. Is it suppose to be this way?
That said;
why the fuck are you using internet explorer
I was using Firefox at the moment while testing Windows 7 on my brother's laptop, but Firefox kept acting up, it froze a lot. So I switch to IE. Oh, if you don't believe me, look it up, it seems a lot of people are having issues with Firefox working with Windows 7 on a few things.
Posted 15 years ago2009-10-27 20:11:02 UTC Post #274877
1) Bad HTML! http://validator.w3.org/
2) JavaScript password protection? Seriously? Create a standard HTML form and let the server do the thinking.
Oskar Potatis Oskar Potatis🦔
Posted 15 years ago2009-10-27 20:11:59 UTC Post #274878
yeah I need it to redirect to an erroor page if its incorrect, or redirect to the actual page if its correct
Unbreakable UnbreakableWindows 7.9 Rating!
Posted 15 years ago2009-10-27 20:13:51 UTC Post #274879
doesn't really help me solve anyhing Potatis... thanks though
Unbreakable UnbreakableWindows 7.9 Rating!
Posted 15 years ago2009-10-27 20:18:49 UTC Post #274880
I was going to mention about using some sort of "remotely hosted" CGI script service where all you have to do, is to just simply copy and paste a simple JavaScript snippet on to your webpage. A lot of these remotely hosted services are free, also. Example: http://cgi.resourceindex.com/Remotely_Hosted/Password_Protection/
Posted 15 years ago2009-10-27 21:19:35 UTC Post #274886
Google is your friend. Have you ever heard of '.htaccess' and '.htpasswd'?
They are very interesting filenames that you should look into. Right now, because any other solution is a really bad idea.
Penguinboy PenguinboyHaha, I died again!
Posted 15 years ago2009-10-27 21:43:23 UTC Post #274887
I hear you Penguinboy.

I just happen to have the services of a paid web host for my various websites. It's not much, only $12 annually. This said web host, just like other web hosts out there, offer what is called a "password protected directory" feature. It is easy to use, no programming or coding necessary on the back end of things (server).

Now, my question is, does this solution also fall under your list of bad ideas?
Posted 15 years ago2009-10-27 21:58:31 UTC Post #274888
It probably uses .htaccess in the background.
Penguinboy PenguinboyHaha, I died again!
Posted 15 years ago2009-10-27 22:33:54 UTC Post #274889
D'oh!....

Interesting, I'm going to have to look in to that with my web host, and see what's up. Always on the prowl to learn more, you know! Carry on, mate....
Posted 15 years ago2009-10-27 23:37:43 UTC Post #274890
Seriously, password protect anything [b]client side AND by JavaScript[/b]??

You really should consider something else. There are much more effective and easier ways to do this. Pretty much every hosting service allows PHP, ASP, or whatever other thing allows you to do this server-side.
Posted 15 years ago2009-10-28 00:41:13 UTC Post #274891
I agree. That's why I suggested the remotely hosted CGI scripts option, it's good for those that do not know how to set up server side scripts or modules. But if your web host offers a password protected directory, then take advantage of it, since it could also be using .htaccess the way Penguinboy suggested. Client side scripts like JavaScript and DHTML does have it's uses, but there are certain jobs that should be left to server side apps like PHP, ASP, CGI, and others like them.
You must be logged in to post a response.