Java Script

Started by
7 comments, last by Woody FX 20 years, 10 months ago
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
Advertisement
Well, I think you can probably make an external &#106avascript 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:


  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!");  

I'll have a link to the TriFaze website as soon as possible. It's still currently being designed, by myself of course! =) I'll update the URL and my signature as soon as possible.Feel free to send me a message on Yahoo! or AOL IM™. =)
Bear in mind you''ll never have a secure authentication if you use &#106avascript.<br><br>I don''t know why you want to authenticate users, but if you''re using &#106avascript 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???
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
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!
That''s the browser''s box - nothing you can do about it.
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.

Wielder of the Sacred Wands
[Work - ArenaNet] [Epoch Language] [Scribblings]

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