Html Password Script.

liunx

Guest
I want a password script. Though i want to see if it is possible to have it as html NOT JavaScript. I don't think it is possible but if there is a "html" password script that asks you 'The Password" as soon as you enter the page. Can someone please tell me.<br />
Because if the script was "JavaScript", a user who disabled javascript could sneak past?<!--content-->Without javascript, you can do it only with a server side language like PHP, ASP, Perl etc. because because HTML can not read or write from or to another file.<!--content-->HTML is markup, not scripting. Which naturally means you can't do any kind of scripting with it.<!--content-->this might be of some help, of course i didnt write it. Got it from a guide(idiots guide) but its not too shabby. Not top notch but gives you decent security. <br />
<br />
step 1: <br />
place this code/tag somewhere within the body of the page you want the link at: <br />
<br />
<A HREF=http://www.webdeveloper.com/forum/archive/index.php/"javascript:GetPassword()">link</A> <br />
<br />
step 2: <br />
on that same page, between the </HEAD> tag and the <BODY> tag put this code: <br />
<br />
<SCRIPT LANGUAGE="JavaScript"> <br />
<!-- <br />
function GetPassword() { <br />
window.open("jspass.htm", "","width=225,height=50") <br />
} <br />
//--> <br />
</SCRIPT> <br />
<br />
step 3: <br />
now, when someone hits the "link" tag in step one, you'll be sent to the next HTML page. This is the entire page you will create exactly as I write it below and call it "jspass.htm". This is a password page, kinda a between page in my mind. This page will ask for a password. Basically the password will be the name of the page you want to goto. Since only you and the people with the name of the page can input it and goto that page, it works nicely. No password is ever contained in the script for someone to get. The name of whatever page you want to goto is the password. Get it? Here is the jpass.htm page exactly as it should be(NOTE: you will notice within this code the ext. of the target page is considered to end in .htm, but you can change this to .html if you like): <br />
<br />
<HTML> <br />
<HEAD> <br />
<TITLE>Password Required</TITLE> <br />
</HEAD> <br />
<br />
<SCRIPT LANGUAGE="JavaScript"> <br />
<!-- <br />
<br />
function SubmitPassword(frm) <br />
{ <br />
// <br />
// Get the value entered into the text box <br />
// <br />
var password = frm.pw.value <br />
// <br />
// Convert it to lowercase <br />
// <br />
password = password.toLowerCase() <br />
// <br />
// Add the .htm extension <br />
// <br />
var loc = password + ".htm" <br />
// <br />
// Make sure the user entered something <br />
// <br />
if (password != "") <br />
{ <br />
// <br />
// If so, send the browser there <br />
// <br />
opener.location.href = <!-- m --><a class="postlink" href="http://www.webdeveloper.com/forum/archive/index.php/loc">http://www.webdeveloper.com/forum/archive/index.php/loc</a><!-- m --> <br />
} <br />
// <br />
// Close this window <br />
// <br />
window.close() <br />
} <br />
<br />
//--> <br />
</SCRIPT> <br />
<br />
<BODY BGCOLOR="#CCCCCC"> <br />
<br />
<FORM> <br />
This page requires a password:<BR> <br />
<INPUT TYPE="TEXT" NAME="pw" SIZE=15> <br />
<INPUT TYPE="BUTTON" VALUE="OK" <br />
onClick="SubmitPassword(this.form)"> <br />
</FORM> <br />
<br />
</BODY> <br />
</HTML> <br />
<br />
<br />
step 4: <br />
just make a target page, and wahtever its name can be your password. <br />
<br />
Now, this isnt 100% perfect but does, to me, create a reasonable amount of security. You might want to put a "noindex, nofollow" meta tag on the target page also to protect it from getting crawled. <br />
<br />
<br />
And i dont believe that disabling javascript will help the person trying to access it because they still have to know the page or it does no good.<br />
<br />
war<!--content-->To fix up some of the errors in that code...<br />
<br />
<br />
<A HREF=http://www.webdeveloper.com/forum/archive/index.php/"javascript:GetPassword()">link</A><br />
<br />
<br />
HREF=http://www.webdeveloper.com/forum/archive/index.php/"javascript:GetPassword()" is incorrrect coding.<br />
Javascript goes in the eventhandlers, NEVER in the href=http://www.webdeveloper.com/forum/archive/index.php/"" eg<br />
<br />
<a href=http://www.webdeveloper.com/forum/archive/index.php/"#" onclick="GetPassword();return false;">link</a><br />
<br />
<br />
<br />
<SCRIPT LANGUAGE="JavaScript"> <br />
<br />
<br />
Should really be<br />
<SCRIPT type="text/JavaScript"> <br />
<br />
<br />
No password is ever contained in the script for someone to get. The name of whatever page you want to goto is the password. Get it? <br />
<br />
<br />
Of cource you could just give the correct link directly to the page to people that are supposed to read it.<br />
It will be just as safe (relying on noone spreading the "password"/link), much easier and also work in browsers without JavaScript.<br />
<br />
<br />
<br />
<FORM> <br />
This page requires a password:...<br />
<br />
<br />
Is wrong since you never are alowed to have plain text inside <form>.<br />
<br />
<FORM> <br />
<p><br />
This page requires a password:...<br />
<br />
eg is correct<!--content-->ok then, thanks stefan.<br />
<br />
war<!--content-->comments withdrawn in good faith.<!--content-->Originally posted by warbishop <br />
i didnt write the script step-on. <br />
<br />
<br />
Yes I know, becuse you said so in your post.<br />
<br />
Nice of you to be totally critical.<br />
<br />
:confused: <br />
<br />
Where is the harm in pointing out the errors and offering the correct solution?<br />
<br />
I would in fact think my post is highly constructive and informative and help others code the right way.<br />
<br />
Must just enjoy tearing people down. No wonder you piss so many people off. LOL<br />
<br />
What?!?!<br />
How on earth can posting corrections to a code that is not even yours piss you off?<br />
I didn't say 1 single harsh word against you.<br />
<br />
You need to relax dude...<!--content-->You might want to also check out the following, and I don't think any users are going to get past just because they have JavaScript disabled.<br />
<br />
Encrypted Password script by Rob Heslop<br />
<!-- m --><a class="postlink" href="http://www.dynamicdrive.com/dynamicindex9/password.htm">http://www.dynamicdrive.com/dynamicindex9/password.htm</a><!-- m --><!--content-->Stefan, I don't know why people would be mad at you for fixing their mistakes. Everyone needs to learn.<br />
<br />
warbishop, there is not such thing as a secure javascript password script. Anyone who knew enough about JavaScript could view the source and figure out what's going on.<!--content-->im trying to be nice but i didnt make a mistake, i didnt write the script and it does work fine!!<br />
<br />
war<br />
<br />
and it doesnt matter how many times you view the source if it doesnt contain the password in it.<br />
<br />
that is the whole point of the script<!--content--><FORM> <br />
This page requires a password:... <br />
<br />
--------------------------------------------------------------------------------<br />
<br />
<br />
<br />
Is wrong since you never are alowed to have plain text inside <form>. <br />
<br />
<FORM> <br />
<p> <br />
This page requires a password:... <br />
<br />
eg is correct<br />
<br />
<br />
Stefan, I never heard that before. Do you happen to have a link to an article or resource about that? Perhaps it's "supposed to" be done a certain way but browsers accept either?...<!--content-->Originally posted by Bullschmidt <br />
Stefan, I never heard that before. Do you happen to have a link to an article or resource about that? <br />
<br />
Here is a link to the HTML Spec<br />
<!-- m --><a class="postlink" href="http://www.w3.org/TR/html4/interact/forms.html#h-17.3">http://www.w3.org/TR/html4/interact/forms.html#h-17.3</a><!-- m --><br />
<br />
Here is the exact description of what you can have in a <form><br />
<br />
<!ELEMENT FORM - - (%block;|SCRIPT)+ -(FORM) <br />
<br />
On this page you can read up on what that means <br />
<!-- m --><a class="postlink" href="http://www.w3.org/TR/html4/intro/sgmltut.html">http://www.w3.org/TR/html4/intro/sgmltut.html</a><!-- m --><br />
<br />
but the important thing is that it is missing %inline;, and text is inline-level content, thus you may not place text directly under <form><br />
<br />
You have to eg use a <p> or <div> in between<br />
<!ELEMENT P - O (%inline;)* <br />
<!ELEMENT DIV - - (%flow;)*<br />
which as you can see may hold inline content (%flow; = %block; + %inline;).<br />
<br />
<br />
Perhaps it's "supposed to" be done a certain way but browsers accept either?... <br />
<br />
Browsers errorcorrection are normally able to recover from a huge number of code errors. Relying on browser error correction is however sloppy/amature coding practices.<!--content-->If you wanted a basic password protection and didn't want to learn a server-side language and have an Apache server you could have chosen to use .htpasswd and .htaccess method to protect the online page, or directory.<!--content-->
 
Back
Top