So I have this query:

    $code = substr(md5(mt_rand()) . password_hash(mt_rand(), PASSWORD_DEFAULT), mt_rand(0,5),mt_rand(15,30)) . substr(md5(mt_rand()) . password_hash(mt_rand(), PASSWORD_DEFAULT), mt_rand(3,7),mt_rand(11,20));
    $dateRegistered = new DateTime(date("Y-m-d H:i:s", time()));
    $codeSql = "UPDATE users SET resetPasswordDate = STR_TO_DATE(?, '%d-%m-%Y'), resetPasswordCode = ? WHERE email=?";
                    $statement2 = mysqli_stmt_init($connection);
                    if (!mysqli_stmt_prepare($statement2, $codeSql)){
                        header("Location: passwordForgot?error=sqlError");
                        mysqli_stmt_close($statement);
                        mysqli_close($connection);
                        exit();
                    }
                    else{
                        mysqli_stmt_bind_param($statement, "sss", $dateRegistered, $code, $email);
                        mysqli_stmt_execute($statement);
                    }

For some reason the table doesn't get updated. I tried removing the date to see if it'd work, but It didn't.

0 Answers