HTML Submit Blank Form Fields

Discussion in 'HTML' started by kagreen2002@yahoo.com, Apr 3, 2008.

  1. Guest

    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.
     
    , Apr 3, 2008
    #1
    1. Advertising

  2. wrote:
    > 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.

    --
    Take care,

    Jonathan
    -------------------
    LITTLE WORKS STUDIO
    http://www.LittleWorksStudio.com
     
    Jonathan N. Little, Apr 3, 2008
    #2
    1. Advertising

  3. Gazing into my crystal ball I observed writing in
    news::

    > 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.

    --
    Adrienne Boswell at Home
    Arbpen Web Site Design Services
    http://www.cavalcade-of-coding.info
    Please respond to the group so others can share
     
    Adrienne Boswell, Apr 4, 2008
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Matthew Margolis

    Ruby CGI and blank form fields

    Matthew Margolis, Jan 30, 2005, in forum: Ruby
    Replies:
    2
    Views:
    130
    Martin DeMello
    Jan 30, 2005
  2. Megha Vishwanath
    Replies:
    3
    Views:
    720
    Megha Vishwanath
    Jul 20, 2004
  3. rob c
    Replies:
    4
    Views:
    336
    McKirahan
    Dec 30, 2005
  4. alan_atwood
    Replies:
    2
    Views:
    201
  5. Replies:
    3
    Views:
    702
Loading...

Share This Page