Sanitize your input data first.
$password = filter_input(INPUT_POST, 'password', FILTER_SANITIZE_STRING);
Hash your password string
$hashedPassword = hash('sha512', $password);
A better way to hash the password would be to use the new password hash API
$hashedPassword = password_hash($password, PASSWORD_DEFAULT);