0

I'm connected to the database, when I echo all of the variables work, but they not insert to the database.

Here is the code:

$stmt = $conn->prepare("INSERT INTO users (`USERNAME`, `PASSWORD`, `ID`) VALUES (?, ?, ?)");

$INITIAL_ID = "UNX80G";
$INITIAL_USER = INITIAL_USERNAME;
$first_hash = hash('sha256', INITIAL_PASSWORD);
$second_hash = hash('sha512', $first_hash);
$third_hash = hash('sha512', $second_hash);
$final_hash = password_hash($third_hash, PASSWORD_ARGON2I, ['memory_cost' => 1024, 'time_cost' => 4, 'threads' => 1]);

$stmt->bind_param("sss", $INITIAL_USER, $final_hash, $INITIAL_ID);

$stmt->execute();

And here is the logs:

PHP Notice:  Use of undefined constant PASSWORD_ARGON2I - assumed 'PASSWORD_ARGON2I' in /var/www/html/utils/mysql.php on line 29
PHP Warning:  password_hash() expects parameter 2 to be integer, string given in /var/www/html/utils/mysql.php on line 29
Dharman
  • 30,962
  • 25
  • 85
  • 135
  • 1
    `PASSWORD_ARGON2I - Use the Argon2i hashing algorithm to create the hash. This algorithm is only available if PHP has been compiled with Argon2 support.` Apparently your version of PHP has not been compiled with this support, so it's failing. – aynber Nov 19 '20 at 18:03
  • 2
    I think you are practicing OVERKILL with all that hashing – RiggsFolly Nov 19 '20 at 18:04
  • 1
    As for the reason why you can't see any data in the database it is probably because you have error reporting silenced. [How to get the error message in MySQLi?](https://stackoverflow.com/a/22662582/1839439) – Dharman Nov 19 '20 at 18:08

0 Answers0