Greetings, sorry about the pain. Your pain is due to being less flexible. Not a concern do hamstring stretching and combine with ice three times a day, your pain will be almost cured.
Next Steps
get to see a physio with knowledge about posture correct and massage/trigger point therapy. this is best way to find out why you had pain at the first place.
Health Tips
if possible hire physio as your trainer for a month to get back your core strength. etc. if any questions do let me know