Solar and stellar flares and their effects on planets