website password system

Miscellaneous Forums/General Discussion/website password system

Hiya, what's the best way to have password restricted areas on your website so that members can logon and then view their own private page and/or pages for members only etc? Do you know of any free software (no ads) that can do this or is it best to code from scratch in perl or php or something? I've seen one made in perl before using https...

Anyway advice much appreciated, thanks.

ASP.NET & ADO.NET

.htaccess

OK thanks guys. Any more votes?

Will ASP.Net only work on Windows PCs with .Net installed?

ASP.NET runs on the server, the server has to be Windows and have the .NET framework.

The client just needs a browser.

If you're trying to start up some sort of community/member site you could possibly benefit from using a CMS (content management system). There's several open-source ones that are pretty customizable. Atleast this would give you a solid foundation to start out with. Drupal is one of the more popular ones. From my experience it's very flexible in functionality, but requires a bit of work to get it exactly like you want it. e107 is another CMS, and the one I'm currentl using.

http://www.opensourcecms.com/
Scroll down on the left bar you'll see a list of CMS's with demo sites and user rating.

PHP + cookies are the best way and 100% compatible for any server (win, linux, mac etc.). The price for an webspace is with this nothing more expensively.

If you are going down the CMS route I strongly recommend Joomla - www.joomla.org

hmm interesting, yes I had considered a content management system earlier. Boiled: Thanks for the info about the ASP Server.

If you are going down the CMS route I strongly recommend Joomla - www.joomla.org


So do I, but make sure you keep up with security releases, particularly for any modules you install with it.

(I use it on squeakyduck)

PHP (or ASP) + SQL

I've heard that www.typo3.com is very powerfull.

my vote is on php + sql + cookies too... it is super easy... no-brainer even

If you're coding from scratch, you need to read either "Learning PHP & MySQL" or "Programming PHP" both published by O'Reilly.

Invaluable.

PHP and MySQL

Another vote for ASP.NET and either sql server (the free one should do fine for low volume web sites) or mysql.

PHP & MySQL all the way baby.

Another vote for asp.net, 2.0 has an inbuilt membership and roles system which will do all of this for you mostly with a few drag and drops.

PHP & MySQL for me too.

hmm, I don't actually know if the server I'm currently using is windows or not, and if not, that pretty much rules out ASP and SQL Server unless I want to switch to another server. Thanks all for your votes.

Does anyone have any links to password system example code?

This code assumes you've Posted data from a form on the last page and the user hit 'log in'

<?php
session_start();

$username = $_POST[username];
$password = $_POST[password];

$db_name_x = "database";
$table_name_x = "table";
$connection_x = @mysql_connect("localhost","root", "password") or die(mysql_error());
$db_x = @mysql_select_db($db_name_x,$connection_x) or die(mysql_error());

$sql_x ="SELECT * FROM $table_name_x ORDER BY username";
$result_x = @mysql_query($sql_x,$connection_x) or die(mysql_error());

while ($row_x = mysql_fetch_array($result_x)) {

	$Username = $row_x['username'];
	$Password = $row_x['password'];
	$name = $row_x['name'];
	$admin = $row_x['admin'];

		
	if ($Username == $username) {
			
		$PASSWORD = md5($password);
		if ($PASSWORD == $Password) {

			$_SESSION[logged] = "yes";
			$_SESSION[name] = $name;
			$_SESSION[username] = $username;
			$_SESSION[admin] = $admin;


		}
			
	}
}

?>


When you stored the usernames and passwords, just store the password as md5($password); this hashes the password so people can't see what they are if they hack your sql.

name and admin are optional... you just have a header piece of php that displays alternate pages for admin, member, and non-logged people. And you can use their name on the page somewhere.... you could store any data you want into the database....

the _X's are because this is from an include I use in lots of pages, and I added the _X so if for some reason I used the non-_Xed version of the same SQL loader, it wouldn't overwrite the varaibles... I'm too lazy to remove them... it doesn't matter.


on the password check IF statement you could echo error msgs if the password isn't correct but the username was... or not.. I normally don't, cause that would alert someone that the username they used was right and the password wasn't... I typically go by name, so the username and password are both hidden, so it adds that much more security.


Also... you can SELECT the username rather than everything, and not run through it all... you would want to do that for lots of users (wont matter under 100 or so) but I didn't trust it when I wrote this...

regardless.. this works.

sounds good thanks.

Most of the hosting servers today run on linux systems and depending on the contract a lot of them offer the mysql/php combination.

that code posted by H&K is not entirely secure (and potentially heavy on server load).

If you can, make sure you have the PEAR modules installed and use PEAR DB and possibly PEAR AUTH to create a much more secure login system.

ok thanks for the updat.

I use 123ehost.com to host my site... they offer that as a standard part of the package.