can we see the code for the existing system?
other than maybe fixing the code you have, were generally not in the habbit of building complete solutions for people.
here is a link to a free php book. may i suggest you take a look at it. should get you started.
otherwise, you might want to go search over at hotscripts you might find a ready made solution.