New classes of codes, namely extended modified prime sequence codes (EMPSC) and difference codes, both having an ideal in-phase cross-correlation (IPCC) value of one, are suggested for spectral-amplitude-coding optical code-division multiple-access communication systems. The general structure of the system is discussed with simpler encoder and decoder architectures based on fiber Bragg gratings. Since the influence of multiuser interference can be completely removed due to ideal IPCC, the performance analyses of the proposed codes have been carried out by incorporating the effects of phase-induced intensity noise (PIIN), shot noise, and thermal noise at the receiver, employing Gaussian approximation. Assuming typical system parameters, evaluation results show that with an increase in code weight, the maximum number of accommodative users in the system can be increased as well as significant improvements in bit error probability for a given number of active users. For the same code weight, the difference codes can support a greater number of simultaneous users than the other. It is found that the effects of PIIN dominate compared to shot noise and thermal noise at large powers, whereas the effects of PIIN and shot noise are highly reduced at low powers, so that thermal noise becomes a more influential limitation factor. In comparison with earlier codes, the error performance of EMPSC is similar to that of modified quadratic congruence codes, while difference codes resemble those codes developed based on Steiner systems.