PHP and MYSQL is the best tools for this job
You cant cut and paste a solution here. It requires bespoke code.If anyone has code they can post, that would be greatly appreciated.
You could look into using a CMS like drupal which has that functionality inbuilt out of the box but there is a steep learning curve
Which ever you decide you will have some work to do