Well this isn't as easy as it seems. Well, ok it's easy but just a bit time consuming.
Please specify what resources you have available; MYSQL, PHP etc...
There are plenty of open source free scripts that would probably do the job, but without knowing what your limitations are we can't point you in the right direction.