Compound and direct processes in proton elastic scattering from 31P and 62Ni