PDA

View Full Version : Login and Password code



Kevin1201
08-28-2007, 10:09 PM
I have a question and i hope someone can help. I want to have a page on a freinds site be password protected. He is using front page 2000 and wants to have a page that has a log on box that will then re-direct you into the protected page or however that works. There will be multiple users with different passwords. I have searched a few codes on this site but we can't get any of them to work. HHEEEEELLLPPP

Rockonmetal
08-28-2007, 10:15 PM
You may have heard this but there Javascript isn't a good way todo this. But if you can't do or don't know if you can do server scripts then i'll look... I think I might know one that was pretty good hold on while i get it

Kevin1201
08-28-2007, 10:17 PM
OK thanks, I'm patiently awaiting the code.. Thanks

Rockonmetal
08-28-2007, 10:20 PM
Ok, I got it... Here it is... this uses Javscript you SHOULDN'T use it for user data with private information like street addresses, credit card numbers, or anything else...



<HEAD>

<SCRIPT LANGUAGE="JavaScript">
<!-- I highly suggest to add atleast some protection to make the script into an external js document... that way its just a tiny bit more secure... -->

function LogIn(){
loggedin=false;
username="";
password="";
username=prompt("Username:","");
username=username.toLowerCase();
password=prompt("Password:","");
password=password.toLowerCase();
if (username=="guest" && password=="login") {
loggedin=true;
window.location="home-page.html";
}
if (username=="guest2" && password=="login2") {
loggedin=true;
window.location="home-page2.html";
}
if (loggedin==false) {
alert("Invalid login!");
}
}
</SCRIPT>

<BODY>

<center>
<form><input type=button value="Login!" onClick="LogIn()"></form>
</center>



If you don't know how to edit the code i'll show you what to do *in order to add more users, and remove...*

Kevin1201
08-28-2007, 10:24 PM
when i copy and paste the code into the page and hit preview, it just shows the html code ??

Rockonmetal
08-28-2007, 10:35 PM
when i copy and paste the code into the page and hit preview, it just shows the html code ??
Uh, by that meaning ok, let me show you how to insert it




<html>
<HEAD>
<SCRIPT LANGUAGE="JavaScript">
function LogIn(){
loggedin=false;
username="";
password="";
username=prompt("Username:","");
username=username.toLowerCase();
password=prompt("Password:","");
password=password.toLowerCase();
if (username=="guest" && password=="login") {
loggedin=true;
window.location="home-page.html";
}
if (username=="guest2" && password=="login2") {
loggedin=true;
window.location="home-page2.html";
}
if (loggedin==false) {
alert("Invalid login!");
}
}
</SCRIPT>
<BODY>
<center>
<form><input type=button value="Login!" onClick="LogIn()"></form>
</center>
</body>
</html>


If that doesn't work, then I don't know what will...

Kevin1201
08-28-2007, 10:58 PM
Yea, I don't know either. I tried it but it won't work. It just keeps showing up on the page as html. ?

Rockonmetal
08-29-2007, 12:27 AM
Oh i no why

ok, change this
where it says

<script type="javascript">
Change it to

<script type="text/javascript">

Kevin1201
08-29-2007, 12:43 AM
Wow, I got excited for a minute thinking that might work but nope. I'm thinking that front page doesnt like the code or something. I'm sooooooofrustrated. I have been fighting this all day almost. Thanks

Rockonmetal
08-29-2007, 02:15 AM
Did you try in your web browswer or is it just not working, I'm sorry man I don't know what that is...

Kevin1201
08-29-2007, 02:17 AM
Yea, Ive tried just about everything. I'll keep messing with the code. Thanks for all the help.

thetestingsite
08-29-2007, 03:31 AM
A suggestion would be to drop FrontPage and use a simple plain text editor such as Notepad or Notepad++ (or Mac/Linux equivalent). I haven't really looked at the code that much, but if you are having a problem with it just showing the source then you may want to try my suggestion. If that still doesn't work, I'll look at the code to see if it's something in there.

Hope this helps.

robb9790
08-30-2007, 12:21 AM
Yea, I don't know either. I tried it but it won't work. It just keeps showing up on the page as html. ?


just a question

did you change the part that i highlighted to that page url?

<html>
<HEAD>
<SCRIPT LANGUAGE="JavaScript">
function LogIn(){
loggedin=false;
username="";
password="";
username=prompt("Username:","");
username=username.toLowerCase();
password=prompt("Password:","");
password=password.toLowerCase();
if (username=="guest" && password=="login") {
loggedin=true;
window.location="home-page.html";
}
if (username=="guest2" && password=="login2") {
loggedin=true;
window.location="home-page2.html";
}
if (loggedin==false) {
alert("Invalid login!");
}
}
</SCRIPT>
<BODY>
<center>
<form><input type=button value="Login!" onClick="LogIn()"></form>
</center>
</body>
</html>

Kevin1201
08-30-2007, 04:53 PM
Hi, Ive tried everything. I decided to go with another code that does work, however, it will only allow me to put in one user and password. Any ideas on how the code should look if I wanted to add another user? Thank a million for the help

Kevin1201
08-30-2007, 04:57 PM
Sorry I forgot to put the link for the code DUH! http://www.dynamicdrive.com/dynamicindex9/password.htm
Thanks

Rockonmetal
08-30-2007, 05:00 PM
Yeah I know how to its really easy... hold on and I'll just test out to see if it works...

Rockonmetal
08-30-2007, 05:02 PM
<script>
//Encrypted Password script- By Rob Heslop
//Script featured on Dynamic Drive
//Visit http://www.dynamicdrive.com

function submitentry(){
password = document.password1.password2.value.toLowerCase()
username = document.password1.username2.value.toLowerCase()
passcode = 1
usercode = 1
for(i = 0; i < password.length; i++) {
passcode *= password.charCodeAt(i);
}
for(x = 0; x < username.length; x++) {
usercode *= username.charCodeAt(x);
}
//CHANGE THE NUMBERS BELOW TO REFLECT YOUR USERNAME/PASSWORD
if(usercode==134603040&&passcode==126906300)
//CHANGE THE NUMBERS ABOVE TO REFLECT YOUR USERNAME/PASSWORD
{
window.location=password+".htm"}
else{
alert("password/username combination wrong")}
}
if(usercode==134603040&&passcode==126906300)
//CHANGE THE NUMBERS ABOVE TO REFLECT YOUR USERNAME/PASSWORD
{
window.location=password+".htm"}
else{
alert("password/username combination wrong")}
}
</script>

<form name="password1">
<strong>Enter username: </strong>
<input type="text" name="username2" size="15">
<br>
<strong>Enter password: </strong>
<input type="password" name="password2" size="15">

<input type="button" value="Submit" onClick="submitentry()">
</form>

That should work, if you see where it says "if" then it ends with "Else" just copy those two functions and it should work great! Hopefully...

Kevin1201
08-30-2007, 06:16 PM
THANKS!! works good

Rockonmetal
08-30-2007, 07:23 PM
Your welcome, just make sure to click the thank this user for this post for the one that worked... *because that way it show which one really worked

Twey
08-30-2007, 07:26 PM
I wrote an improved version of this script (http://www.twey.co.uk/?q=encpass), but it's still inferior to doing the job properly, entirely server-side.

kark
07-25-2008, 04:16 AM
Hey,

I recently coded a login form type of thing in Java, but
I need some help getting the account, like where all users have their own page.
How do I do this anyhelp?

HTMLcss
09-03-2008, 08:01 AM
I'd also like to know that if somebody knows of one.
Also is there a script that can automatically run a username and password into the script that's here (http://www.dynamicdrive.com/dynamicindex9/password.htm) and email me the numbers?
(They would enter the username and password into a form, possibly with more info).

magicyte
09-03-2008, 11:09 PM
By the way, I think I know why it showed the HTML code. I don't think that you posted it in the HTML part of FrontPage.

-magicyte

dragonfighter120
09-18-2009, 02:29 AM
if you are using word then it won't work. Try using crimson editor, smultron, taco, pagespinner or Kompozer. Also remember the extension .htm or .html!

forum_amnesiac
09-18-2009, 06:01 AM
If you need proper security then you definitely need to use something serverside, eg PHP & MYSQL.

I used to use a script for passwords until I realised that anybody who thought about viewing the source code could gain access to the protected parts of the site.

It is really not very difficult to do this in PHP, there are plenty of scripts out there, and the extra security is invaluable.

I did it originally with a simple 2 column table, ID & password, if the ID is not found, or the password is not matched then deny access.

The other big advantage to this type of system is that it is easy to give the site owner the ability to maintain the database, eg add new ID's, change passwords, delete ID's. This way there is no need to change code each time you want to amend access to the system.

falu26
11-18-2009, 05:14 PM
nice code (on page 1)
but Rockonmetal could you please tell me how to insert more users and passwords???
thnx

falu26
11-18-2009, 05:27 PM
n ya...i would like each user to have a respective password...
as in user1 to have "password" as a password
user2 to have something like "unique" or some thing....but respective passwords...

octopressink
09-19-2010, 12:19 AM
I know this is three years late, but I just saw this....you need to make sure the code is saved as .html and not .txt.

RiverFoot
12-16-2010, 06:16 PM
try adding .html to the end of the file your creating :p