can you help with md5 protection please?

Riona2k3

Dedicated Member
Dedicated Member
May 9, 2003
208
0
113
Leeds
Hi,

I am new to the php scripting and trying to make a registration page.
I have got the script working but i need to md5 protect the passwords.
Could someone help me with this please?

PHP:
<?php
include ("db_connect.inc");

$query="INSERT INTO accounts (login,password) VALUES ('$_POST[login]','$_POST[password]')";
if(!mysql_db_query($dbname,$query,$link_id)) die(mysql_error());
echo "success in database entry.";

echo "<br />";
echo "User added to database.</a>";
?>

Edit: Managed to fix the problem my self by changing

PHP:
$query="INSERT INTO accounts (login,password) VALUES ('$_POST[login]','$_POST[password]')";

To

PHP:
$query = sprintf( "INSERT INTO accounts (login,password) VALUES ('%s','%s')", addslashes($_POST['login']), md5($_POST['password']));

Thanx
Chris
 
Last edited:

Dataforce

LOMCN VIP
VIP
Apr 15, 2003
2,080
0
283
PHP:
$query="INSERT INTO accounts (login,password) VALUES ('".addslashes($_POST[login])."','".md5($_POST[password])."')";

would also have worked
 

Kaori

LOMCN MiR3 Queen!
VIP
Jun 3, 2004
3,584
38
285
Canada
is your registration page SSL?

if not then the password should be salted+md5'ed before you send over the network.