EDIT: Semi-solved. I can now store my insecure passwords in my DB and also log in. Next step is to give it another attempt at creating a secure mechanism for forgotten passwords (along with md5 encryption).

---

I'm trying to remove the md5 hashing from my passwords, so I can easily send the user his password to his email, in case he forgets it (I tried several solutions to generate a new password using md5 encryption, but I failed. So I want to do it this simple - yet a bit insecure - way).

I have the following code which stores the password in the database in a hashed format. I can also log in with no trouble... however as mentioned, I want to remove the hashing. I removed 

```
$new_password = password_hash($upass, PASSWORD_DEFAULT);

```

and changed '$new\_password' to '$upass'.

When I look at my database, I can see a non-hashed password which is exactly what I want. However, I can no longer log with a nonhashed password. Isn't that strange? What am I possibly doing wrong? 

Here's a snippet of my registration code.

```
include_once 'dbconnect.php';

if(isset($_POST['btn-signup']))
{
$uname = $MySQLi_CON->real_escape_string(trim($_POST['user_name']));
$email = $MySQLi_CON->real_escape_string(trim($_POST['user_email']));
$upass = $MySQLi_CON->real_escape_string(trim($_POST['password']));
$phone = $MySQLi_CON->real_escape_string(trim($_POST['phone']));

$new_password = password_hash($upass, PASSWORD_DEFAULT);

$check_email = $MySQLi_CON->query("SELECT user_email FROM users WHERE user_email='$email'");
$count=$check_email->num_rows;

if($count==0){

    $query = "INSERT INTO users(user_name,user_email,user_pass,user_phone) VALUES('$uname','$email','$new_password','$phone')";

    if($MySQLi_CON->query($query))
    {
        $msg = "<div class='alert alert-success'>
                    <span class='glyphicon glyphicon-info-sign'></span> &nbsp; successfully registered !
                </div>";
    }
    else
    {
        $msg = "<div class='alert alert-danger'>
                    <span class='glyphicon glyphicon-info-sign'></span> &nbsp; error while registering !
                </div>";
    }
}
else{

    $msg = "<div class='alert alert-danger'>
                <span class='glyphicon glyphicon-info-sign'></span> &nbsp; sorry email already taken !
            </div>";

}

$MySQLi_CON->close();

```

}