View Full Version : Javascript Login/Password+cookie + registration form?
talpa
03-21-2010, 05:57 PM
Hello guys I am new to the forum however I have a problem.
I am trying to find a Javascript which will make a registration form enter username + password + date of birth and this can be wrote into a cookie and then the user can access the other parts of the website.
I know its better to use something like php & mysql for this however I need to do this in Javascript and I seem to find it very difficult to even find something similar to this on the internet.
Can anyone help me?
Thanks
talpa
03-21-2010, 07:57 PM
can no one help me?
djr33
03-21-2010, 08:55 PM
Javascript is not, will not be, and is not meant to be secure.
Therefore it is nearly useless to create a Javascript "security" system like user registration.
It is certainly possible to make this, but it won't be secure or useful. It's up to you. User who don't know much may not know the difference, but others will be able to.
If you need security, use server side code.
If you want to continue with Javascript, you can do a few things, though I'm not sure what the point is: if you are storing it in a COOKIE, then that just stays on the user's computer-- it won't be there for very long (since they are periodically deleted by the browser, so there's no point in assuming it'll last more than a week, and no way to know even that) and you will never have access to the information. The idea of using serverside code is that 1) you will have secured information on the server for verification and 2) this will be something to compare against and store for YOUR reference later, such as registration by email address so you can update your visitors.
If you just use Javascript, these things will not be available.
Anyway, think about what your point is and see what you want to do.
http://dynamicdrive.com/dynamicindex9/password.htm
or
try to redirect to the 'password'-- which is the name of the next page. Have a form, have a field called "password" and have the browser to to [field].htm, so if you type in "password", then it will be "password.html". This is actually fairly secure, but awkward.
Also:
http://tools.dynamicdrive.com/password/
that uses .htaccess which IS serverside and can be secure, but is less controllable than PHP, etc.
The problem with all of these is that they aren't allowing you to create custom accounts and store them in cookies. As I said above this is pointless, but:
1. Create a form.
2. Use Javascript to check submission of form-- don't actually send the data, but just verify with Javascript onclick.
3. If data is missing or appears to be invalid, refuse and tell them to change it (alert, etc.)
4. If it's all valid, then store it in a cookie and redirect to the page.
5. If the user loads a page and the cookie is not set, redirect them to the registration page. If it is set, then allow them to continue.
But it cannot be stressed enough that there are problems here:
1. Users can turn off javascript-- then what are you doing to do?
2. Users can trick Javascript (since it's not secured on the server)
3. These "user accounts" will NEVER exist anywhere except on the visitor's computer-- what's the point?
The only reason I can think of for using this sort of script is to create "customized" pages:
1. Users must log in with their "name".
2. Now on your pages you can create a welcome message "Welcome, Name!"
I'm not sure exactly how useful this is, but it's possible...
talpa
03-21-2010, 09:26 PM
so if i wanted to make a new user and existing user link and when they sign in and then gets redirected to a page. How can this be achieved?
I know Javascript is used for generally form validation however this is what is driving me crazy I cannot see to find any information on this. Just pages like this one http://dynamicdrive.com/dynamicindex9/password.htm explaining that you have to set a username and password first. I know in php/mysql it would connect to a database and etc but this is javascript... :rolleyes:
djr33
03-21-2010, 11:27 PM
You cannot create permanent user accounts in Javascript. You will just waste your time trying.
This MUST be serverside.
Using a database (or text files on the server) is not just a way to do it, but it is the ONLY way to do it. Since Javascript cannot store information to the server then there is no way to track user accounts.
Every single time a user visits your site they will be a "new user". You can simulate user accounts for every single visit, but they will not be stored and later available.
They will also not be secure and not be able to "connect" in any way to you, your server or the other visitors. In other words, their "account" will only actually be on their computer and nowhere else and not even stored on their computer for a long time, possibly only the time they are actually browsing your site.
talpa
03-22-2010, 12:27 AM
Thanks for the updates I shall reply tomorrow :)
djr33
03-22-2010, 01:16 AM
Also, note that if you only want this to be "live" and that's the reason to use Javascript, you can use AJAX (a method within Javascript) to dynamically interact with a serverside system so that you can use a database, PHP, etc., but within the commands of Javascript (indirectly, but to a user on a compatible machine it will seem smooth).
But of course this means coding both the PHP and Javascript for everything.
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.