I think you've probably answered your own question fella.
Your EML light 💡 WILL come on if your oil pressure, or oil level falls below a pre-programmed point to warn you.
It's almost certainly come on because the oil is now ALL OVER rather than IN your engine.
Your number one absolute priority is to replenish the oil to the correct level on your dipstick. I would then use as much ******* roll as you need to to mop up the worst of the spillage. Then use something like Autoglym engine & machine cleaner to remove the rest.
If your Oil cap is so loose that it comes off, replace it, otherwise you're going to have a repeat job. M Most cars have a bit of weepage on rocker box covers, so check all the securing nuts are tight, and again, if they are, a new gasket is an easy fix.
In my experience, oil caps rarely come undone. Usually owners or garages fail to put them back tightly, or forget to put them back after servicing the car.