This is not a trivial undertaking and there are thousands of ways to accomplish this. It depends on many factors - e.g. will your users be able to "publish" their created forms, can the users update their forms (brings in form- and data-version management issues), will you provide a visual designer, will you provide a declarative design language, how do you want to store the data filled into a form, are the fields chosen by the user pulled from a finite set of available fields or can the user invent wholly new fields, etc.
In a full-blown electronic forms package, you are, essentially, creating a visual IDE for form creation along with a "compiler" that produces the fill-able, run-time implementation of the user's forms. To make the system useful, you will also have to include management features (search, filing, import, export, etc.).
If you don't want to tackle these issues yourself, there are many eforms packages out there. Cost ranges from free to tens of thousands of dollars.