I'm trying to lose some weight, and had to watch some youtube videos for review, so I just spent the last 5 hours (about 3500 calories) on an elliptical doing max resistance and max incline, and 2 hours later it feels like needles are sticking in me as well as having a sore lower back. How should I recover?
You've given yourself a bad case of Delayed Onset Muscle Soreness (DOMS), which is very likely to get worse before it gets better. (DOMS usually peaks the day after exercise, so if you're feeling it a mere 2 hours after exercise then it's probably going to be really bad tomorrow.) Like an imminent hangover, there's unlikely to be anything you can do to get out of this.(1) Don't bother with ibuprofen either - DOMS is not an inflammatory condition, and NSAIDs like ibuprofen are no better than placebo at treating it.(2)(3) You're just going to have to wait it out.
In the future, you should aim to avoid this by not making sudden, drastic increases to your activity level. If you'd started by spending 15-30 minutes on the machine instead, doing this a couple of times per week and gradually increasing the intensity or duration as you can tolerate it, then you'd likely be able to endure a workout like this without temporarily crippling yourself. (Although even then, 5 hours is incredibly long. Comparing this to running, a marathon would take the average marathon runner around 4 hours, and no one would consider attempting to run a marathon with no prior training. Aiming to do 2-4 sessions per week, each an hour long, might be a more reasonable goal, if this is to be your chosen exercise modality.)
Ensuring that your workouts are only a small increment more strenuous than what you're accustomed to will also work better towards your weight loss goals by avoiding leaving yourself so sore that you don't want to exercise again for a whole week.