You have used the password_hash()
under wrong syntax.
password_hash
— Creates a password hash
password_hash()
creates a new password hash using a strong one-way hashing algorithm. password_hash() is compatible with crypt(). Therefore, password hashes created by crypt() can be used with password_hash().
Replace your Insert Query with this one:
Method One:
$query= "INSERT INTO `members`(`name`,`email`,`password`) VALUES('".mysqli_real_escape_string($link,$_POST['name'])."','".mysqli_real_escape_string($link,$_POST['email'])."','".password_hash($_POST['password'],PASSWORD_DEFAULT)."')";
Method Two:
$name = mysqli_real_escape_string($link,$_POST['name']);
$email = mysqli_real_escape_string($link,$_POST['email']);
$password = password_hash($_POST['password'],PASSWORD_DEFAULT);
$query= "INSERT INTO `members`(`name`,`email`,`password`) VALUES('".$name."','".$email."','".$password."')";
Both the methods will produce the same output as expected but we are escaping the strings before itself in the method two.
Example:
<?php
echo password_hash("rasmuslerdorf", PASSWORD_DEFAULT)."\n";
?>
Output:
$2y$10$.vGA1O9wmRjrwAVXD98HNOgsNpDczlqm3Jq7KnEd1rVAGv3Fykk1a
Note: Your Script is vulnerable to SQL Injections
even thought use escape the strings
before insertion. Try to use prepared statements
so that it avoids the SQL Injection
s that are possible in the Normal Query.