During the last decades, photocathode rf guns have been proven to be successful for providing very high quality electron beams required for vacuum ultraviolet and x-ray free-electron lasers. Beam dynamics simulations show that the electron beam quality in a rf gun depends strongly on the beam dynamics in the vicinity of the cathode. Therefore, the injection process plays a significant role in the beam performance. Several codes are available to simulate the beam dynamics in the gun. They are able to track the beam under the influence of external fields and space charge forces, but details of the emission processes are still missing in these simulations. In photocathode rf guns, the electron beams have a high charge density. Especially during emission from the cathode, the electrons have a very low velocity and experience high longitudinal space charge forces counteracting the applied accelerating field. Because of the space charge field, some part of the electrons emitted from the cathode might move backward to the cathode where they can produce secondary electrons. A high electric field in the gun cavity, on the other hand, generates a large amount of dark current. If the field-emitted electrons from the cathode or any other surface inside the cavity hit the cathode, secondary electrons can be produced as well. For a detailed understanding of the electron beam and dark current in a rf gun, simulations including a model of the secondary electron emission are necessary. In this paper, a simple model is discussed with an application to the beam dynamics at high emission phases in rf guns. Detailed simulations have been done in comparison to measurements at the Photo Injector Test Facility at DESY in Zeuthen. The primary electrons which are photoemitted from the cathode and the secondary electrons which are produced by the primaries at the cathode could be clearly distinguished in measurements and simulations.