Dear Student,
When molten NaCl is electolysed then NaCl breaks into two components Na+ ions and Cl- ions where Na+ ions go to cathode and Cl- ions got to anode releasing chlorine gas at anode and depositing Sodium metal at cathode.
But if the solution is aqueous NaCl then due to less discharge potential of H+ it moves towards cathode and form H2 gas which undesirable and chloride goes to anode to liberate chlorine gas and both of these gases can get mixed together.The remaining ion that is Na+ and OH- form NaOH.
I hope you find the answer useful.
Regards.