If I forget to perform Ghusl after Janabah and later realize it 6 to 7 hours after reciting Salah, what should I do to rectify my prayer and ensure my worship is valid?
If you discovered that your Ghusl was definitely wring after 6 to 7 hours, you must redo the Ghusl in the proper way and perform your obligatory Prayer after the valid Ghusl. Invalid Ghusl means every worship performed after it is invalid until you perform a valid Ghusl.
Wassalam.