Java Script
Hi,
Trying to setup a login page to a part of a Web-Page!
I though Http Authentication was the best way.. its simple to implement but is kind of scary for the user when it appears..
I''ve seen Java Script can do the same thing and it looks a whole lot nicer!
Do any of you know of any tutorials where i can learn to do this, found a few on the web but they want my CC details before they let you see them..... which i fair enough but cant aford it... if i could would have bought a book!
Thanks for you help,
Brian
Well, I think you can probably make an external javascript file (.js), and place it like this:
<script src="MyJScript.js">
// Nothing goes in here
</script>
and you can create a function called Login(). It would be something like this:
I hope this is what you wanted. BTW, you can use "else if" statements for multiple users:
<script src="MyJScript.js">
// Nothing goes in here
</script>
and you can create a function called Login(). It would be something like this:
function Login(user, pass) { if ((user == "Admin") && (pass == "Root")) // Send user to authorized page else // Incorrect alert("Incorrect username or password!");}
I hope this is what you wanted. BTW, you can use "else if" statements for multiple users:
if ((user == "User1") && (pass == "Pass1")) // Send to authorized pageelse if ((user == "User2") && (pass == "Pass2")) // Send to authorized pageelse // Incorrect alert("Incorrect username or password!");
Bear in mind you''ll never have a secure authentication if you use javascript.<br><br>I don''t know why you want to authenticate users, but if you''re using javascript anyone can authenticate as anyone else. Waste of time? I think so <img src="smile.gif" width=15 height=15 align=middle><br><br>HTTP authentication is the better option.
HTTP Auth is so ugly...
Is there anyway of changing the appearence of the Window that promps for the used id & password???
Is there anyway of changing the appearence of the Window that promps for the used id & password???
You mean removing the statusbar, locationbar, etc..
self.menubar.visible=false;
self.toolbar.visible=false;
self.locationbar.visible=false;
self.personalbar.visible=false;
self.scrollbars.visible=false;
self.statusbar.visible=false;
Sorcerer
SorcSoft.com -> Homepage | Pictures | FTP Upload | Contact
ICQ: 201024198 | MSN: kleiwegl@hotmail.com
self.menubar.visible=false;
self.toolbar.visible=false;
self.locationbar.visible=false;
self.personalbar.visible=false;
self.scrollbars.visible=false;
self.statusbar.visible=false;
Sorcerer
SorcSoft.com -> Homepage | Pictures | FTP Upload | Contact
ICQ: 201024198 | MSN: kleiwegl@hotmail.com
There is a little gray box that pops up to take the used ID and password.
Rather than have this box i''d like to integrate it to the webpage or least be able to change the appearance of the box!
Rather than have this box i''d like to integrate it to the webpage or least be able to change the appearance of the box!
If you have access to a server-side scripting language like ASP or PHP, you can use a session variable to check whether the user is authenticated or not. When your secure page(s) is processed on the server, check the session variable. If the user isn''t logged in, direct them to a simple HTML form that asks for the login info. If they have a valid username/password/whatever, set the session variable to say that the user has logged in.
Works beautifully.
Works beautifully.
Go with server side scripting. Run a search on User Authentication with PHP, or find an article at sitepoint.com (or another similar site). You can use another language if required, but I would recommend PHP if this is all you need it for, for it will be the simplest to pick up and the most readily available.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement