It's a surprising amount of work to do well.
I would strongly suggest that you have a look at some of the existing free versions which already exist:
Google: "Free forum software"[
^] - it'll probably save you several weeks of work, and a lot of pain.