It's been debated whether he survived the tower falling or not, people have even pointed out a detail of him escaping through the window in the background in the scene where Arthur becomes king (I haven't watched 3 in a long time so I'd have to rewatch to see if I saw that)
My theory is he either escaped and went to live a new life in another kingdom, or was found by the stage hands off screen and taken to Arthur where he was sentenced to the dungron for his crimes.
One theory I had is he escaped to Camelot since its never mentioned in Shrek 3 (and the school Arthur went to was on an island in the middle of the sea, nowhere near another Kingdom so it wasn't in Camelot) . I had even thought about writing a story about this that detailed Charmings survival and what became of him in Camelot after escaping Far Far Away