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
400
Reaction score
44
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

Forum statistics

Threads
473,828
Messages
2,569,736
Members
45,518
Latest member
vlonesshirt

Latest Threads

Top