I'm not going to attempt to tell you that I am right, I will merely give advice on what I think.
Your reaction appears to be an acid/base titration. The phenolphthalein you added to the solution was an indicator. The indicator tells you when a difference in pH (acidic---> basic or vice versa, depending on your indicator) is achieved. The solution turned pink after you added NaOH to the HCl because the pH went from acidic to basic.
I cannot explain the foaming; it seems to me that the gas is water vapor since when you react an acid with a base you get water and a salt. HCl + NaOH----> H2O + NaCl, in your case. The foam was formed as a result of the reaction occurring.
Sorry I can't be more help..Chemistry was never my favorite :/