Hashtag wont work on my password

Joined
Sep 24, 2023
Messages
2
Reaction score
0
Untitled.png
<?php

include("../include/connection.php");

$username = $_POST['username'];
$password = $_POST['password'];

$pass_h = password_hash($password, PASSWORD_DEFAULT);
$query = mysqli_query ($connect, "INSERT INTO admin(username, password, profile) VALUES('$username', 'pass_h', '')");
if($query){
echo "hi";
}else{
echo "fff";
}
?>
 
Joined
Jul 4, 2023
Messages
475
Reaction score
58
small mistake
VALUES('$username', 'pass_h', '')");
it should be $pass_h


BTW,
PHP:
include("../include/connection.php");

$username = mysqli_real_escape_string($connect, $_POST['username']);
$password = mysqli_real_escape_string($connect, $_POST['password']);

$pass_h = password_hash($password, PASSWORD_DEFAULT);
$sql = "INSERT INTO admin(username, password, profile) "
     . "VALUES('$username', '$pass_h', '')";

if (mysqli_query($connect, $sql))
  echo "Record has been successfully added to the database.";
else
  echo "Error while adding the record: " . mysqli_error($connect);

// ...
mysqli_close($connect);

[ what does mysql_real_escape_string() really do? ]
 
Last edited:

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,983
Messages
2,570,187
Members
46,747
Latest member
jojoBizaroo

Latest Threads

Top