UART - getting gibberish data from MAX232 with PIC16F877A mcu
I didn't look at the code, but here are some possibilities:

Lack of bypass cap on the PIC.  Until you fix this, all else is irrelevant.

Possibly not waiting for the UART to be ready before writing a character to it.  Try sending just one character intead of a string.  If that works, then this is a likely cause.



Normally I'd add baud rate to this list, but since you are receiving correctly, that's probably not it.