Man of Honour
The page ID method is great for SEO, too, if you used wording in URLs and a bit of mod_rewrite trickery.
<?php
session_start();
$document_root = dirname(__FILE__);
$document_root = dirname($document_root);
$includes_dir = $document_root.'/includes/';
require $includes_dir.'include.config.php';
require $includes_dir.'include.mysql.php';
?>
<?php
if (!$dbc = mysql_connect($conf_mysql_hostnm, $conf_mysql_usernm, $conf_mysql_passwd)) {
$error = 'MySQL Error, '.mysql_error();
die($error);
}
if (!mysql_select_db($conf_mysql_dbname)) {
$error = 'MySQL Error, '.mysql_error();
die($error);
}
?>
Salt the MD5 thenInquisitor said:Just a quick note:
I'd advise against the use of the MD5 algorithm, as it is no longer secure. The source code for quickly calculating MD5 collisions is freely available on the web now.
Instead, use sha1(). Or if you want to be really sure, you could use HMAC-SHA1
Ah my bad...Dj_Jestar said:Providing you know what you are doing, or can find the script that does it for you, you can find a collision for SHA1 quicker than MD5.
But to put things into perspective, finding a collision for either will take hours, if not days to find. So you won't have to worry about someone gaining access at the click of their fingers, it will require some work, time and patience.
There are a variety of hashing algorithms available with hash() from PHP 5.1.2.
However, a salt is all that is needed, providing you use it wisely.
HTTP requests have one fatal flaw, they are all in plaintext.
So.. to help avoid password sniffing (from packet sniffing,) we can implement a hashing algorithm that takes place on the client, and the server, and is also linked to session_id's to reduce the chances of someone sniffing and stealing the hash'd password + salt and using that to gain access.
All seems a bit complicated and long winded, and it can be at first, but it is currently the safest way to login other than SSL.
SELECT plaintext FROM rainbowtable WHERE hash = hash_to_crack