The shallow flow expansion is used to derive equations describing the flow of fluid in an unconfined aquifer. The expansion, which is carried out to second order, is combined with an approximation accounting for the influence of the capillary fringe to give a model that describes the motion of the phreatic surface as it is affected by the capillarity of the porous medium. The results are derived for the case of an aquifer in contact with a reservoir, with the fluid in the reservoir undergoing a steady periodic motion. A linearized solution of the second-order theory is shown to agree well with an "exact" numerical solution. It is demonstrated using the Iinearized solution that the porous medium capillarity affects the time- averaged mean square height of the phreatic surface of the aquifer in the second-order term, but leaves the first- order term unchanged.