
Making the Form Dance
I haven't done anything completely new here. I declare my string variables at the top, including the content variable we already had plus a name and comment variable. I then use the code described in a previous tutorial to check for passed form variables (the try-catch on lines 40-55). On line 57 I check to make sure that both name and comment are not null. If they aren't, I execute the first block where I thank the person for submitting their comment. If it is blank, I execute the else block, outputting the form.
You may notice how I'm setting the value of the input tags in the form. Why? Well, what happens if someone fills out their name but doesn't fill out a comment? With the value filled out like it is, their name is automatically repopulated into their form so they don't have to type it out again. Go ahead and try it... fill out only one input and hit submit. You'll notice the form doesn't go all blank on you. This is user friendly. We can take error handling a step further as well.