Firstly, you must understand some basic terminology.
Encryption is different then hashing,
In an encryption you turn the data into something else that can be decrypted in order to get the original data back.
In a hash its a one way street. Hash is a mathematical function that can take any amount of data and calculate its hash value, which is alway 32 characters in size using md5 has algorithm. So natuarally its a one way street and you are not going to be able to turn it back from the hash value. This is a good way to store your password, cuz in the event that your database is compromised, the user’s passwords will still be safe.
Anyways, now for the problem, you will need to do something like the following :
//i am going to skip the codes before, this is the code in the if ($valid) block
$model2->password=md5($model->mobilenumber);// storing the hash instead of the original password
if($model->save(false) && $model2->save(false)) //false for disabling validation.
//do the redirect
die('either $model or $model2 havn\'t been successfully saved <img src='http://www.yiiframework.com/forum/public/style_emoticons/default/sad.gif' class='bbc_emoticon' alt=':(' />');
Firstly : You might want to add some random salt to the password when hashing. Unless the passwords are longer then 7 characters (7 character hash’s database are pretty common on the web, so easily crackable)
Secondly: Why do you use mobile number for password, not a safe bet.
Thirdly: you have already saved $model, why save it again?? In my code i saved both at the same time in the code.