just a quick question,
Is this function secure, if not how can I make it more secure?
public function Reg($name, $email, $password)
{
try {
$db=DB();
$state = $db->prepare("INSERT INTO reg (name, email, password) VALUES (:name, :email, :password)");
$state->bindParam("name", $name);
$state->bindParam("email", $email);
$encpass= hash('sha256', $password);
$state->bindParam("password", $encpass, PDO::PARAM_STR);
$state->execute();
return $db->lastInsertId();
} catch (PDOException $e){
exit($e->getMessage());
}
}
As always thanks for any help in advance and its much appreciated for any help you can give
So is this correct
public function Reg($name, $email, $password)
{
try {
$db=DB();
$state = $db->prepare("INSERT INTO reg (name, email, password) VALUES (:name, :email, :password)");
$state->bindParam("name", $name);
$state->bindParam("email", $email);
$hashed_password = password_hash($password, PASSWORD_DEFAULT);
$state->bindParam("password", $hashed_password, PDO::PARAM_STR);
$state->execute();
return $db->lastInsertId();
} catch (PDOException $e){
exit($e->getMessage());
}
}