your code looks correct. one issue I have seen that may be causing your problem is that the code form element does not have a value attribute. Change:
<input type="text" name="code" id="code" />
to:
<input type="text" name="code" id="code" value="" />
I have a number of cases where not adding the value attribute cases the form element not to be posted.