views:

408

answers:

4

Can I create user accounts automatically using HTML, VBScript or JavaScript? By 'account' I mean being able to limit access to pages to authorised users only.

+7  A: 

HTTP Basic Authentication with a .htaccess file might be what you're after.

http://httpd.apache.org/docs/1.3/howto/auth.html

Barry Gallagher
A: 

HTML will not allow you to restrict access. If you are on Windows you can use NT Authentication to secure a file or folder. Then when a user requests that file or folder, they will be prompted for a username and password. But this requires changes in IIS and also having the account(s) added into Active Directory (or at least to the local machine).

Jeff Widmer
+3  A: 

HTML is a declarative language that does nothing but describing what a given page should look like when interpreted. Javascript could provide you with a simple login solution but it is primarily validated client side, therefore not really secure.

So, to restrict certain users access to certain pages, the "easiest" solution will probably be to use a CMS system or scripting language. There is loads of great tutorials online for creating simple login systems. These suggestions obviously require your web server to support the scripting language, possibly the database you choose.

A choice could be the PHP language and the MySQL database. Both widely used and well documented. I found this guide which looks fairly simple.

anderstornvig
A: 

Sure, just use javascript to check if a cookie is set and then use javascript to link to the 'secure' area in the page. I say 'secure' because it only prevents casual browsers from getting there. Anyone who knows about your hidden links can go there without the cookie. Set up a robots.txt file to prevent search engines from indexing the 'secure' area. This might be all you need. In fact without a backend language it's your only real option other than .htaccess, but then if you can handle that you can probably learn some PHP too.

SpliFF