pasty brown discharge, have you ever had this ?

Period was late, started with brown spotting. Only late for a few days , but it only lasted 4 days which is unusual for me, since I am regular (7days). 
I had sex the 4th day( last day )I was just spotting, but intercourse was very painful when deep penetration (only when deep? But it was painful .  A week later I started spotting (brown) like period was starting. I had that for a day and now I almost have no discharge it's very little brown pasty discharge. Pain during intercourse only lasted one day. What could this mean ? Infection?