Hello, I am trying to insert a registration form with password using password_hash() but I am not sure what is wrong with whatever i am doing because the password doesn't get inserted into the database although all the other values do and no errors.

database :
password | varchar(255)

php:

    $res = $conn->prepare("INSERT INTO table(id, name, pass) VALUES(:id, :name, :pass)");

    $id = $_POST['id'];
    $name = $_POST['name'];
    $password = $_POST['password'];
    $password = password_hash($password, PASSWORD_DEFAULT);

    $res->bindParam(':id', $id, PDO::PARAM_STR);
    $res->bindParam(':name', $name, PDO::PARAM_STR);
    $res->bindParam(':pass', $password, PDO::PARAM_STR);

    $res->execute();

html:
<input name="password" type="password" placeholder="Password"

thanks in advance.

Follow through each step and make sure everything is as expected. So check $_POST['password'] holds a value, check that password_hash() doesn't return FALSE and check the error message from your db call.
Everything looks fine from a cod epoint of value.

Your letting the user create their own ID?

My own rookie mistake. the coding is fine. sorry.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.