HTML form doesn't collect data if one or more fields are empty

HoodiboY

New Member
I've created a form for the user to fill out and on submit it is processed and stuff is done with it. Usually just a database query.With the database that I am working with, some fields can be NULL, so the user could leave something blank in some of the fields. However, when testing this, I tried having one or more fields empty, but the form wouldn't really submit anything at all. When I was debugging, almost all the values of the fields, even the ones with text in it, turn out NULL when I retrieve the values from the POST method.The thing is, I need to be able to allow the user to submit a form with some fields blank, as they are not completely necessary. How would I go about this?Do I have to check isset() for everything that could be blank and set it to NULL if it is?Thanks in advance!EDIT: Here is the form code.\[code\]<h1>Please enter a value for all the fields, then click 'add entry'</h1> <div class="container"> <form onsubmit="return confirm('Do you really want to submit the form?');" method="post" action="orgadd.php" id="orgform" name="orgform" > <label for="parent_id">Parent Organization ID</label>: <input type="text" name="parent_id"><br /><br /> <label for="nm">Organization NM</label>: <input type="text" name="org_nm"><br /><br /> <label for="company">Organization SysNM</label>: <input type="text" name="tbr_sysnm"><br /><br /> <label for="address">Type</label>: <input type="text" name="type"><br /><br /> <label for="city">Contact NM</label>: <input type="text" name="contact_nm"><br /><br /> <label for="zip">Financial Info</label>: <input type="text" name="financial_info"><br /><br /> <label for="state">Other Info</label>: <input type="text" name="other_info"><br /><br /> <label for="phone">Active</label>: <input type="text" name="active"><br /><br /> <label for="web_site">URL</label>: <input type="text" name="url"><br /><br /> <input type="submit" value="http://stackoverflow.com/questions/12728312/Add Entry" name="save" /> </FORM> </div>\[/code\]and here is the php processing code :)\[code\]if(isset($_GET['id'])) { $organization_id = $_GET['id']; $parent_organization_id = $_POST['parent_organization_id']; $organization_nm = $_POST['organization_nm']; $tbr_organization_sysnm = $_POST['tbr_organization_sysnm']; $type = $_POST['type']; $contact_nm = $_POST['contact_nm']; $financial_info = $_POST['financial_info']; $other_info = $_POST['other_info']; $active = $_POST['active']; $url = $_POST['url'];\[/code\]After I get the values I simply escape them and perform a query.
 
Back
Top