The problem probably started when jumping in to someone elses post and trying to use a code chunk defined for their specific scenario.
The add to cart works with the form and the server code in conjunction. I can't spot a problem with one without looking at both and even then a description of the precise problem and what you need help on is usually necessary.