In your code, $password
is not a string but the null
value¹. That's because $_POST
does not have key named password
², which in turn happens because you do not have an input element with name="password
in your form.
Adding a name attribute will make things work:
<input type="password" name="password" class="form-control" id="inputpass"
placeholder="Enter a password">
¹ You can verify this with var_dump($password)
.
² This will cause PHP to emit an E_NOTICE
message at the line you are making the assignment. Turning error_reporting
to the maximum with error_reporting(E_ALL);
would make this message appear.