Jump to content

Submiting form with text fields and checkbox's Need help


Go to solution Solved by benanamen,

Recommended Posts

Here is what i need.  I have a form with a bunch of text boxes and check box's that i need to submit to mysql database.  I know how to submit the text boxes just fine with the insert statment.  I have not used check boxes and i need some help on how to insert them into the database.  I need them to be enterened in as a 0 or 1. 

 

Here is the form

<form action="submit.php" method="post">
<table width="1000" border="0" cellspacing="0" cellpadding="0">
<tr>
  <td height="1400" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
    <tr>
      <td width="6%" height="168"> </td>
      <td width="87%"> </td>
      <td width="7%"> </td>
    </tr>
    <tr>
      <td height="37"> </td>
      <td><table width="100%" height="37" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td width="32%" valign="bottom"><input name="water-purveyor" type="text" id="water-purveyor" size="35" /></td>
          <td width="29%" valign="bottom"><input name="meter-num" type="text" id="meter-num" size="10" /></td>
          <td width="39%" valign="bottom"><input type="text" name="permit-num" id="permit-num" /></td>
        </tr>
      </table></td>
      <td> </td>
    </tr>
    <tr>
      <td height="42"> </td>
      <td><table width="100%" height="37" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td width="32%" valign="bottom">
            <input name="manufacturer" type="text" id="manufacturer" size="20" /></td>
          <td width="15%" valign="bottom"><input name="meter-size" type="text" id="meter-size" size="10" /></td>
          <td width="15%" valign="bottom"><input name="model-num" type="text" id="model-num" size="10" /></td>
          <td width="38%" valign="bottom"><input name="serial-num" type="text" id="serial-num" size="18" /></td>
        </tr>
      </table></td>
      <td> </td>
    </tr>
    <tr>
      <td height="62"> </td>
      <td valign="bottom"><table width="100%" height="56" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td width="61%" valign="bottom"><textarea name="mgmt-info" cols="50" rows="1" id="mgmt-info"></textarea></td>
          <td width="39%" valign="bottom"><textarea name="mgmt-phone-contact" cols="30" rows="1" id="mgmt-phone-contact"></textarea></td>
        </tr>
        </table></td>
      <td> </td>
    </tr>
    <tr>
      <td height="63"> </td>
      <td><table width="100%" height="57" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td width="61%" valign="bottom"><textarea name="owner-info" cols="50" rows="1" id="owner-info"></textarea></td>
          <td width="39%" valign="bottom"><textarea name="owner-phone-contact" cols="30" rows="1" id="owner-phone-contact"></textarea></td>
        </tr>
        </table></td>
      <td> </td>
    </tr>
    <tr>
      <td height="37"> </td>
      <td><table width="100%" height="37" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td width="32%" valign="bottom"><table width="100%" border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td width="3%"> </td>
              <td width="21%"><input type="checkbox" name="sab-owner" id="sab-owner" /></td>
              <td width="44%"><input type="checkbox" name="sab-management" id="sab-management" /></td>
              <td width="32%"><input type="checkbox" name="sab-other" id="sab-other" /></td>
            </tr>
          </table></td>
          <td width="29%" valign="bottom"><input name="auth-contact" type="text" id="auth-contact" size="20" /></td>
          <td width="39%" valign="bottom"><input name="auth-phone" type="text" id="auth-phone" size="15" /></td>
        </tr>
      </table></td>
      <td> </td>
    </tr>
    <tr>
      <td height="65"> </td>
      <td><table width="100%" height="56" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td width="32%" valign="bottom"><textarea name="bf-assembly-address" cols="30" rows="1" id="bf-assembly-address"></textarea></td>
          <td width="29%" valign="bottom"><textarea name="onsite-location" cols="20" rows="1" id="onsite-location"></textarea></td>
          <td width="39%" valign="bottom"><textarea name="primary-business" cols="20" rows="1" id="primary-business"></textarea></td>
        </tr>
      </table></td>
      <td> </td>
    </tr>
    <tr>
      <td height="63"> </td>
      <td><table width="100%" height="56" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td width="32%" valign="bottom"><table width="100%" border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td width="62" height="8"> </td>
              <td width="214" height="8"><input type="checkbox" name="new-assembly-yes" id="new-assembly-yes" /></td>
            </tr>
            <tr>
              <td> </td>
              <td><input type="checkbox" name="new-assembly-no" id="new-assembly-no" /></td>
            </tr>
            </table></td>
          <td width="29%" valign="bottom"><table width="100%" border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td width="24%" height="8"> </td>
              <td width="76%" height="8"><input type="checkbox" name="replacement-assembly-yes" id="replacement-assembly-yes" /></td>
            </tr>
            <tr>
              <td> </td>
              <td><input type="checkbox" name="replacement-assembly-no" id="replacement-assembly-no" /></td>
            </tr>
          </table></td>
          <td width="39%"><input type="text" name="new-serial-num" id="new-serial-num" /></td>
        </tr>
      </table></td>
      <td> </td>
    </tr>
    <tr>
      <td height="42"> </td>
      <td><table width="100%" height="42" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td width="7%"> </td>
          <td width="24%"><div style="padding-top:8px; padding-left:4px;"><input type="checkbox" name="poa-secondary" id="poa-secondary" /></div></td>
          <td width="21%"><div style="padding-top:8px"><input type="checkbox" name="poa-primary" id="poa-primary" /></div></td>
          <td width="14%"><div style="padding-top:8px"><input type="checkbox" name="poa-fire-system" id="poa-fire-system" /></div></td>
          <td width="14%"><div style="padding-top:8px; padding-left:4px;"><input type="checkbox" name="poa-landscape" id="poa-landscape" /></div></td>
          <td width="20%"><div style="padding-top:8px; padding-left:4px;"><input type="checkbox" name="poa-portable" id="poa-portable" /></div></td>
        </tr>
      </table></td>
      <td> </td>
    </tr>
    <tr>
      <td height="64"> </td>
      <td><table width="100%" height="58" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td width="33%" valign="bottom"><table width="100%" border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td width="6%"> </td>
              <td width="3%"> </td>
              <td width="26%"><input type="checkbox" name="svb" id="svb" /></td>
              <td width="23%"><input type="checkbox" name="pvb" id="pvb" /></td>
              <td width="21%"><input type="checkbox" name="dc" id="dc" /></td>
              <td width="21%"><input type="checkbox" name="rp" id="rp" /></td>
            </tr>
            <tr>
              <td> </td>
              <td valign="bottom"> </td>
              <td colspan="4"><div style="padding-left:20px;"><input name="toa-other-text" type="text" id="toa-other-text" size="30" /></div></td>
            </tr>
          </table></td>
          <td width="35%">  <input type="text" name="line-pressure" id="line-pressure" /></td>
          <td width="32%"><table width="100%" border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td width="19%"> </td>
              <td width="34%"><input type="checkbox" name="bp-yes" id="bp-yes" /></td>
              <td width="47%"><input type="checkbox" name="bp-no" id="bp-no" /></td>
            </tr>
          </table></td>
        </tr>
      </table></td>
      <td> </td>
    </tr>
    <tr>
      <td height="64"> </td>
      <td><table width="100%" height="63" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td width="83%"> </td>
          <td width="17%" valign="bottom"><table width="100%" border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td height="32" colspan="5" valign="bottom" align="center"><input name="pvb-aioa-psid" type="text" id="pvb-aioa-psid" size="8" /></td>
              </tr>
            <tr>
              <td width="18%" height="25"> </td>
              <td width="28%"> </td>
              <td width="26%"><input type="checkbox" name="pvb-leaked-yes" id="pvb-leaked-yes" /></td>
              <td width="28%" colspan="2"><input type="checkbox" name="pvb-leaked-no" id="pvb-leaked-no" /></td>
              </tr>
          </table></td>
        </tr>
      </table></td>
      <td> </td>
    </tr>
    <tr>
      <td height="56"> </td>
      <td><table width="100%" height="56" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td width="18%"> </td>
          <td width="22%" valign="top"><table width="100%" height="54" border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td width="5%" height="6"> </td>
              <td width="49%"> </td>
              <td width="18%"><input type="checkbox" name="cv1-ct-yes" id="cv1-ct-yes" /></td>
              <td width="28%"><input type="checkbox" name="cv1-ct-no" id="cv1-ct-no" /></td>
            </tr>
            <tr>
              <td height="6"> </td>
              <td colspan="2" align="center"><input type="text" name="cv1-psid" id="cv1-psid" size="6" /></td>
              <td> </td>
            </tr>
            <tr>
              <td height="6"> </td>
              <td> </td>
              <td valign="top"><input type="checkbox" name="cv1-leaked-yes" id="cv1-leaked-yes" /></td>
              <td valign="top"><input type="checkbox" name="cv1-leaked-no" id="cv1-leaked-no" /></td>
            </tr>
          </table></td>
          <td width="22%"><table width="100%" height="54" border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td width="5%" height="6"> </td>
              <td width="49%"> </td>
              <td width="19%"><input type="checkbox" name="cv2-ct-yes" id="cv2-ct-yes" style="background-color:transparent;" /></td>
              <td width="27%"><input type="checkbox" name="cv2-ct-no" id="cv2-ct-no" /></td>
            </tr>
            <tr>
              <td height="6"> </td>
              <td colspan="2" align="center"><input type="text" name="cv2-psid" id="cv2-psid" size="6" /></td>
              <td> </td>
            </tr>
            <tr>
              <td height="6"> </td>
              <td> </td>
              <td valign="top"><input type="checkbox" name="cv2-leaked-yes" id="cv2-leaked-yes" /></td>
              <td valign="top"><input type="checkbox" name="cv2-leaked-no" id="cv2-leaked-no" /></td>
            </tr>
          </table></td>
          <td width="20%" valign="bottom"><table width="100%" border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td height="30" colspan="2" align="center"><input type="text" name="dprv-psid" id="dprv-psid" size="8" /></td>
              <td width="6%"> </td>
              <td width="21%"> </td>
            </tr>
            <tr>
              <td width="54%"> </td>
              <td width="19%"><input type="checkbox" name="dprv-dno-yes" id="dprv-dno-yes" /></td>
              <td> </td>
              <td><input type="checkbox" name="dprv-dno-No" id="dprv-dno-No" /></td>
            </tr>
          </table></td>
          <td width="18%" valign="bottom"><table width="100%" border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td height="32" colspan="5" valign="bottom" align="center"><input name="pvb-cvha-psid" type="text" id="pvb-cvha-psid" size="8" /></td>
              </tr>
            <tr>
              <td width="20%" height="25"> </td>
              <td width="20%"> </td>
              <td width="9%"> </td>
              <td width="24%"><input type="checkbox" name="pvb-cvha-leaked-yes" id="pvb-cvha-leaked-yes" /></td>
              <td width="27%"><input type="checkbox" name="pvb-cvha-leaked-no" id="pvb-cvha-leaked-no" /></td>
            </tr>
          </table></td>
        </tr>
      </table></td>
      <td> </td>
    </tr>
    <tr>
      <td height="145"> </td>
      <td><table width="100%" height="143" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td width="18%" height="129"> </td>
          <td width="22%" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td width="54%"> </td>
              <td width="18%"><input type="checkbox" name="cv1-cleaned-yes" id="cv1-cleaned-yes" /></td>
              <td width="28%"><input type="checkbox" name="cv1-cleaned-no" id="cv1-cleaned-no" /></td>
            </tr>
            <tr>
              <td> </td>
              <td><input type="checkbox" name="cv1-replaced-yes" id="cv1-replaced-yes" /></td>
              <td><input type="checkbox" name="cv1-replaced-no" id="cv1-replaced-no" /></td>
            </tr>
            <tr>
              <td height="40"> </td>
              <td valign="bottom"><input type="checkbox" name="cv1-rkd-yes" id="cv1-rkd-yes" /></td>
              <td valign="bottom"><input type="checkbox" name="cv1-rkd-no" id="cv1-rkd-no" /></td>
            </tr>
            <tr>
              <td height="22"> </td>
              <td><input type="checkbox" name="cv1-springs-yes" id="cv1-springs-yes" /></td>
              <td><input type="checkbox" name="cv1-springs-no" id="cv1-springs-no" /></td>
            </tr>
            <tr>
              <td> </td>
              <td><input type="checkbox" name="cv1-guide-yes" id="cv1-guide-yes" /></td>
              <td><input type="checkbox" name="cv1-guide-no" id="cv1-guide-no" /></td>
            </tr>
            <tr>
              <td> </td>
              <td><input type="checkbox" name="cv1-other-yes" id="cv1-other-yes" /></td>
              <td><input type="checkbox" name="cv1-other-no" id="cv1-other-no" /></td>
            </tr>
          </table></td>
          <td width="22%" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td width="51%" height="22"> </td>
              <td width="21%"><input type="checkbox" name="cv2-cleaned-yes" id="cv2-cleaned-yes" /></td>
              <td width="28%"><input type="checkbox" name="cv2-cleaned-no" id="cv2-cleaned-no" /></td>
            </tr>
            <tr>
              <td> </td>
              <td><input type="checkbox" name="cv2-replaced-yes" id="cv2-replaced-yes" /></td>
              <td><input type="checkbox" name="cv2-replaced-no" id="cv2-replaced-no" /></td>
            </tr>
            <tr>
              <td height="40"> </td>
              <td valign="bottom"><input type="checkbox" name="cv2-rkd-yes" id="cv2-rkd-yes" /></td>
              <td valign="bottom"><input type="checkbox" name="cv2-rkd-no" id="cv2-rkd-no" /></td>
            </tr>
            <tr>
              <td height="22"> </td>
              <td><input type="checkbox" name="cv2-springs-yes" id="cv2-springs-yes" /></td>
              <td><input type="checkbox" name="cv2-springs-no" id="cv2-springs-no" /></td>
            </tr>
            <tr>
              <td> </td>
              <td><input type="checkbox" name="cv2-guide-yes" id="cv2-guide-yes" /></td>
              <td><input type="checkbox" name="cv2-guide-no" id="cv2-guide-no" /></td>
            </tr>
            <tr>
              <td> </td>
              <td><input type="checkbox" name="cv2-other-yes" id="cv2-other-yes" /></td>
              <td><input type="checkbox" name="cv2-other-no" id="cv2-other-no" /></td>
            </tr>
          </table></td>
          <td width="20%" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td width="56%" height="22"> </td>
              <td width="22%"><input type="checkbox" name="dprv-cleaned-yes" id="dprv-cleaned-yes" /></td>
              <td width="22%"><input type="checkbox" name="dprv-cleaned-no" id="dprv-cleaned-no" /></td>
            </tr>
            <tr>
              <td> </td>
              <td><input type="checkbox" name="dprv-replaced-yes" id="dprv-replaced-yes" /></td>
              <td><input type="checkbox" name="dprv-replaced-no" id="dprv-replaced-no" /></td>
            </tr>
            <tr>
              <td height="40"> </td>
              <td valign="bottom"><input type="checkbox" name="dprv-rkd-yes" id="dprv-rkd-yes" /></td>
              <td valign="bottom"><input type="checkbox" name="dprv-rkd-no" id="dprv-rkd-no" /></td>
            </tr>
            <tr>
              <td height="22"> </td>
              <td><input type="checkbox" name="dprv-springs-yes" id="dprv-springs-yes" /></td>
              <td><input type="checkbox" name="dprv-springs-no" id="dprv-springs-no" /></td>
            </tr>
            <tr>
              <td> </td>
              <td><input type="checkbox" name="dprv-guide-yes" id="dprv-guide-yes" /></td>
              <td><input type="checkbox" name="dprv-guide-no" id="dprv-guide-no" /></td>
            </tr>
            <tr>
              <td> </td>
              <td><input type="checkbox" name="dprv-other-yes" id="dprv-other-yes" /></td>
              <td><input type="checkbox" name="dprv-other-no" id="dprv-other-no" /></td>
            </tr>
          </table></td>
          <td width="18%" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td width="48%" height="22"> </td>
              <td width="28%"><input type="checkbox" name="pvb-cleaned-yes" id="pvb-cleaned-yes" /></td>
              <td width="24%"><input type="checkbox" name="pvb-cleaned-no" id="pvb-cleaned-no" /></td>
            </tr>
            <tr>
              <td> </td>
              <td><input type="checkbox" name="pvb-replaced-yes" id="pvb-replaced-yes" /></td>
              <td><input type="checkbox" name="pvb-replaced-no" id="pvb-replaced-no" /></td>
            </tr>
            <tr>
              <td height="40"> </td>
              <td valign="bottom"><input type="checkbox" name="pvb-rkd-yes" id="pvb-rkd-yes" /></td>
              <td valign="bottom"><input type="checkbox" name="pvb-rkd-no" id="pvb-rkd-no" /></td>
            </tr>
            <tr>
              <td height="22"> </td>
              <td><input type="checkbox" name="pvb-springs-yes" id="pvb-springs-yes" /></td>
              <td><input type="checkbox" name="pvb-springs-no" id="pvb-springs-no" /></td>
            </tr>
            <tr>
              <td> </td>
              <td><input type="checkbox" name="pvb-guide-yes" id="pvb-guide-yes" /></td>
              <td><input type="checkbox" name="pvb-guide-no" id="pvb-guide-no" /></td>
            </tr>
            <tr>
              <td> </td>
              <td><input type="checkbox" name="pvb-other-yes" id="pvb-other-yes" /></td>
              <td><input type="checkbox" name="pvb-other-no" id="pvb-other-no" /></td>
            </tr>
          </table></td>
        </tr>
      </table></td>
      <td> </td>
    </tr>
    <tr>
      <td height="29"> </td>
      <td><table width="100%" height="29" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td width="18%"> </td>
          <td width="82%"><table width="100%" height="29" border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td width="29%"> </td>
              <td width="19%" valign="top"><input name="valve-num" type="text" id="valve-num" size="12" style="height:14px;" /></td>
              <td width="14%">
                <input type="checkbox" name="repaired" id="repaired" />
              </td>
              <td width="15%">
                <input type="checkbox" name="replaced" id="replaced" />
              </td>
              <td width="23%">
                <input type="checkbox" name="both-ok" id="both-ok" />
              </td>
            </tr>
          </table></td>
        </tr>
      </table></td>
      <td> </td>
    </tr>
    <tr>
      <td height="62"> </td>
      <td><table width="100%" height="60" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td width="18%"> </td>
          <td width="22%" valign="top"><table width="100%" height="41" border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td width="25%" height="19"> </td>
              <td width="29%"> </td>
              <td width="20%"><input type="checkbox" name="ft-cv1-ct-yes" id="ft-cv1-ct-yes" /></td>
              <td width="26%"><input type="checkbox" name="ft-cv1-ct-no" id="ft-cv1-ct-no" /></td>
            </tr>
            <tr>
              <td colspan="3" align="center"><input name="ft-cv1-psid" type="text" id="ft-cv1-psid" size="8" /></td>
              <td> </td>
            </tr>
          </table></td>
          <td width="22%" valign="top"><table width="100%" height="41" border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td width="25%" height="19"> </td>
              <td width="25%"> </td>
              <td width="24%" valign="top"><div style="padding-left:4px;"><input type="checkbox" name="ft-cv2-ct-yes" id="ft-cv2-ct-yes" /></div></td>
              <td width="26%"><input type="checkbox" name="ft-cv-ct-no" id="ft-cv2-ct-no" /></td>
            </tr>
            <tr>
              <td colspan="3" align="center"><input type="text" name="ft-cv2-psid" id="ft-cv2-psid" size="8" /></td>
              <td> </td>
            </tr>
          </table></td>
          <td width="20%" align="center"><input name="ft-dprv-psid" type="text" id="ft-dprv-psid" size="8" /></td>
          <td width="18%" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td width="36%" height="22"> </td>
              <td colspan="2" align="center"><input name="ft-ai-psid" type="text" id="ft-ai-psid" size="4" /></td>
              <td width="3%"> </td>
              <td width="20%"> </td>
            </tr>
            <tr>
              <td height="25"> </td>
              <td width="14%"> </td>
              <td colspan="2" align="center"><input name="ft-cv-psid" type="text" id="ft-cv-psid" size="3" /></td>
              <td> </td>
            </tr>
          </table></td>
        </tr>
      </table></td>
      <td> </td>
    </tr>
    <tr>
    <td colspan="3" height="32"></td>
    </tr>
    <tr>
      <td height="54"> </td>
      <td valign="bottom"><table width="100%" height="" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td width="49%" rowspan="2" valign="bottom"><textarea name="tc-info" cols="45" rows="1" id="tc-info"></textarea></td>
          <td width="51%" rowspan="2" valign="bottom"><textarea name="tc-info2" cols="40" rows="1" id="tc-info2"></textarea></td>
        </tr>

      </table></td>
      <td> </td>
    </tr>
    <tr>
      <td height="37"> </td>
      <td valign="bottom"><table width="100%" border="0" cellspacing="0" cellpadding="0" style="padding-bottom:4px;">
        <tr>
          <td width="23%"><input name="itb" type="text" id="itb" size="20" /></td>
          <td width="26%"><input name="certified-tester-num2" type="text" id="certified-tester-num2" size="15" /></td>
          <td width="26%"><input name="date-failed" type="text" id="date-failed" size="15" /></td>
          <td width="25%"><input name="tk-serial-num" type="text" id="tk-serial-num" size="20" /></td>
        </tr>
      </table></td>
      <td> </td>
    </tr>
    <tr>
      <td height="39"> </td>
      <td valign="bottom"><table width="100%" height="33" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td width="23%"> </td>
          <td width="52%"> </td>
          <td width="25%"> </td>
        </tr>
      </table></td>
      <td> </td>
    </tr>
    <tr>
<td height="38"> </td>
<td valign="bottom"><table width="100%" height="32" border="0" cellspacing="0" cellpadding="0">
        <tr>
<td width="23%"><input name="ftb" type="text" id="ftb" size="20" /></td>
<td width="26%"><input name="ftb-certified-tester-num" type="text" id="ftb-certified-tester-num" size="20" /></td>
<td width="26%"><input name="date-passed" type="text" id="date-passed" size="15" /></td>
<td width="25%"><input name="ftb-tk-serial-num" type="text" id="ftb-tk-serial-num" size="20" /></td>
        </tr>
      </table></td>
      <td> </td>
    </tr>
    <tr>
      <td height="123"> </td>
      <td><textarea name="comments" id="comments" cols="105" rows="3"></textarea></td>
      <td> </td>
    </tr>
  </table></td>
</tr>
<tr>
  <td> </td>
</tr>
<tr>
  <td> </td>
</tr>
<tr>
  <td> </td>
</tr>
<tr>
  <td> </td>
</tr>
</table>
</form>

Here is just a sample of the insert code that i have:

<?php
$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "myDB";
$table = "sysform";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}

$water-purveyor = $_POST['water-purveyor'];
$meter-num = $_POST['meter-num'];
$permit-num = $_POST['permit-num'];
$svb = $_POST['svb'];
$pvb = $_POST['pvb'];
$dc = $_POST['dc'];
$rp = $_POST['rp'];


$sql = "INSERT INTO $table ('water-purveyor', 'meter-num', 'permit-num','...', 'svb', 'pvb', 'dc', 'rp')
VALUES ('$water-purveyor', '$meter-num', '$permit-num','$...', '$svb', '$pvb', '$dc', '$rp')";



if ($conn->query($sql) === TRUE) {
    echo "New record created successfully";
} else {
    echo "Error: " . $sql . "<br>" . $conn->error;
}

$conn->close();
?> 

Can anyone help me on how to under stand how to sumbit the check box's to where i have a 1 or 0.  Also i need to use the get function to pull the data back to the form.

 

Here is the statment i have for that  just as an example:

<?php
$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "myDB";
$table = "sysform";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}

$water-purveyor = $_POST['water-purveyor'];
$meter-num = $_POST['meter-num'];
$permit-num = $_POST['permit-num'];
$svb = $_POST['svb'];
$pvb = $_POST['pvb'];
$dc = $_POST['dc'];
$rp = $_POST['rp'];


$sql="SELECT * from $table where sequence = '".$_GET["sequence"]."' ";
$rs=mysql_query($sql,$conn) or die(mysql_error());
$result=mysql_fetch_array($rs);
?>



<form action="" method="get">
<table width="1000" border="0" cellspacing="0" cellpadding="0">
<tr>
  <td height="1400" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
    <tr>
      <td width="6%" height="168"> </td>
      <td width="87%"> </td>
      <td width="7%"> </td>
    </tr>
    <tr>
      <td height="37"> </td>
      <td><table width="100%" height="37" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td width="32%" valign="bottom"><input name="water-purveyor" type="text" id="water-purveyor" size="35" value="<?php echo '$water-purveyor'?>" /></td>
          <td width="29%" valign="bottom"><input name="meter-num" type="text" id="meter-num" size="10" value="<?php echo '$meter-num'?>" /></td>
          <td width="39%" valign="bottom"><input type="text" name="permit-num" id="permit-num" value="<?php echo '$permit-num'?>" /></td>
        

      </tr>
</table>
</form>

The way check boxes work, unlike other form elements, is if the checkbox is not checked, nothing whatsoever about it gets submitted.

 

So, you would need to see if the check box name isset. If it isset, it will always be not empty. (The value actually = on)

$sab-owner = isset($_POST['sab-owner']) ? 1 : 0;

Now, there is another option where you set the default value in the database to zero. When you do your insert, if you didn't insert a 1 for that column, it will automatically be zero. If you go that route, I would make a comment in the code that says that is what is happening so anyone else reading the code, including yourself years later will know whats going on.

Edited by benanamen

With all that input I would not use a GET for my input.  Set your form method to be POST instead.

 

Also - your checkboxes don't have a value clause which is usual.  Of course you still have to check if they are set but then you can simply use the value as the value to be saved.

 

if (isset($_POST['checkbox1']))
    $checkbox1 = $_POST['checkbox1'];
else
   $checkbox1 = 0;     // or whatever you want saved

  • Solution

OP, so your not confused,

 

$sab-owner = isset($_POST['sab-owner']) ? 1 : 0;

 

 

$checkbox1 = isset($_POST['checkbox1']) ? 1 : 0;

 

does the same exact thing as

 

if (isset($_POST['checkbox1']))


    $checkbox1 = $_POST['checkbox1'];


else


   $checkbox1 = 0;     // or whatever you want saved

 

 

 

What I showed you is a Ternary Operator. It would behoove you to know how to use it. There is no need to have a value for the form check box.

 

$checkbox1 = isset($_POST['checkbox1']) ? 'this_is_my_check_box_insert_value_not_a_number' : 0;

 

A string will require to be quoted, a number no quotes.

Edited by benanamen

What do you mean "how to display" your checkbox on a get.  The incoming query string will look like:  checkboxname=checkboxvalue.  Of course if you don't have an actual value= attribute on your checkbox tag (as I pointed out earlier), then 'checkboxvalue' may be non-existent in the string.

 

A better checkbox tag:

echo "<input type='checkbox' name='chkbox1' id='chkbox1' value='1'>  <label for='chkbox1'>Selection 1</label>"; 

 

Here I assign a value of '1' to the choice of 'Selection 1'.  You can just as well use 'Selection 1' in your value attribute, but that is up to the situation you are in.

1 - you should not use a GET input directly without first checking that it is proper and not malicious.

2 - What you are showing me is that you are outputting a checkbox with a value that is equal to the very same checkbox that you must have already received.   What is the point of this?

What i need to do is show the check box and text box as it is a document i want to print out later.  If there is another way to show everything i would be happy to have that shown to me.  I am doing this for a potential client.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.