Posted: Wed Sep 18, 2002 12:19 pm
Strange, this doesn't seem to work for me
CRYPT_MD5 is 0 for me (WinXP Home, Apache 2.0.35, PHP 4.2.2, MySQL something like 3.4). I'm using the following code to register / edit profile:
And the following code to login:
I always get 'whaa!' als result, it doesn't matter if i use a correct or wrong password. Everything is inserted and retrieved well from the database. I would be very pleased with your help.
Code: Select all
extract($_POST);
if($password1 != $password2)
{
die('The passwords must be the same!');
}
$salt = '$1$' . substr(MD5(microtime() . getmypid()),0,12);
$password1 = md5crypt($password1, $salt);
$query = ($action == 'new') ? 'INSERT ' : 'UPDATE ';
mysql_query("
$query {$prefix}users
SET user_name = '$username',
user_pass = '$password1',
user_mail = '$email'
WHERE user_name = '$username'
")
or die(mysql_error());Code: Select all
$result = mysql_query('
SELECT user_pass
FROM users
WHERE user_name = ''' . $_POSTї'username'] . '''
');
extract(mysql_fetch_array($result));
if(md5crypt($_POSTї'password'], $user_pass) == $user_pass)
{
echo('login correct!');
}
else
{
echo('whaa!');
}