HTML Submit Blank Form Fields

K

kagreen2002

I have a form that updates a database table row. The form sends back
all fields that are filled in, and my CGI updates those fields. My
problem is if a user blanks out a field, that field is not sent
back, ,and so the CGI does not update the field to blank.

Is there a way for the form to submit all fields regardless of whether
data is entered in them?

Thanks.
 
J

Jonathan N. Little

I have a form that updates a database table row. The form sends back
all fields that are filled in, and my CGI updates those fields. My
problem is if a user blanks out a field, that field is not sent
back, ,and so the CGI does not update the field to blank.

Is there a way for the form to submit all fields regardless of whether
data is entered in them?

No, but what you can do is have your CGI script have a list of
*expected* fields and compare to to the list of *received* field and any
ones missing use null value, i.e., you preset them with an acceptable
value. Your script should be restricted to only those field names that
you have predefined. Know exactly what type and quantity of data is
permissible. Check it before using such data and discard or deal with it
appropriately if it does not conform. If you don't you most likely have
an insecure and possibly dangerous script.
 
A

Adrienne Boswell

Gazing into my crystal ball I observed (e-mail address removed) writing in
I have a form that updates a database table row. The form sends back
all fields that are filled in, and my CGI updates those fields. My
problem is if a user blanks out a field, that field is not sent
back, ,and so the CGI does not update the field to blank.

Is there a way for the form to submit all fields regardless of whether
data is entered in them?

Thanks.

If you are using input type text, you should receive an empty value upon
submission. The only exceptions are radio, checkbox and select.
However, if you specify a default value, you should get those as well,
eg:
<input type="radio" value="" name="field" checked> Default
<input type="radio" value="a" name="field">A
<input type="checkbox" value="" name="field" checked> Default
<input type="checkbox" value="a" name="field">A
<select name="field">
<option value="" selected>Default</option>
<option value="a">A</option>
</select>

Again, as Jonathan said, your server side script should check these
fields before sending anything to the database.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top