Sounds like he has an aftermarket temp gauge.
Given the fact that the aftermarket temp gauge worked AND the factory temp gauge worked AND the Check Engine Light came on, sounds like you removed the wrong sensor.
You removed the coolant temperature sensor (Which is right next to the temperature sending unit). The coolant temperature sensor reports to the ECU what engine coolant temperature is for closed loop versus open loop fueling.
The temperature sending unit just operates the gauge, nothing more.
So in short, remove that OTHER sensor next to where you tapped for the aftermarket gauge's sender and put the sender in that hole. Hope you didn't throw away the coolant temperature sensor.