Jun 19 2010, 09:39 PM
i have a problem. i am saving the users password at registration as md5.
when the user is trying a login, i check if the entered username and password is equal to the entry in the database. for that, i have to convert the entered password into md5, to make it comparable:
thats the code to find the user in my controller class
$user = $this->User->find(array('email' => $this->data['User']['email'], 'password' => md5($this->data['User']['password'])), array('id', 'email'));
if(empty($user) == false)
now if print the query to check what it looks like, one thing is odd. no matter what password i enter it is ALWAYS(!) the same md5 key:
SELECT `User`.`id`, `User`.`email` FROM `users` AS `User` WHERE `email` = 'email@example.com' AND `password` = 'd41d8cd98f00b204e9800998ecf8427e' LIMIT 1
no wonder i get no results and the variable "$user" is empty...i get "d41d8cd98f00b204e9800998ecf8427e" everytime..
thats a mystery....does somebody know the answer? i'd be soooo happy
many many thanks
btw: thats my view
<?php echo $form->create('User', array('action' => 'login'));?>
<?php echo $form->input('email');?>
<?php echo $form->input('password');?>
<?php echo $form->submit('Login');?>
<?php echo $form->end(); ?>
Jan 28 2011, 11:45 PM
I think I have the same problem... Anyone knows any solution?
Jan 30 2011, 01:18 AM
The md5 value being display is for an empty string.
I would begin by debugging your $this->data because it sounds like it is not being set properly.
Another question, why not just use the Auth component to do this? You can follow my simple tutorial here to set it up in less than 10 minutes: CakePHP Login System