bettyatolive Posted July 13, 2006 Share Posted July 13, 2006 I have a form with 25 controls in it. I need to submit the form if atleast one of it's value is not null i.e. If all the values are null then the form should not be submitted. If either one of the control of the form is not null then the form should be submitted. Can somebody help me out how to do tht Plz...??? Quote Link to comment https://forums.phpfreaks.com/topic/14465-submitting-a-form/ Share on other sites More sharing options...
GingerRobot Posted July 13, 2006 Share Posted July 13, 2006 Can we see your form? That would help. Quote Link to comment https://forums.phpfreaks.com/topic/14465-submitting-a-form/#findComment-57216 Share on other sites More sharing options...
brown2005 Posted July 13, 2006 Share Posted July 13, 2006 you looked at the tutorials? Quote Link to comment https://forums.phpfreaks.com/topic/14465-submitting-a-form/#findComment-57217 Share on other sites More sharing options...
brown2005 Posted July 13, 2006 Share Posted July 13, 2006 if((!$username) || (!$password) || (!$number)){ if(!$username) { $error .= "<tr><td>You have not entered your username.</td></tr>"; } if(!$password) { $error .= "<tr><td>You have not entered your password.</td></tr>"; } if(!$number) { $error .= "<tr><td>You have not entered the verification code.</td></tr>"; } }use the above putting all your posts into it, that checks if either are empty thenif($error){echo"there is an error";}else{echo"there is no error";} Quote Link to comment https://forums.phpfreaks.com/topic/14465-submitting-a-form/#findComment-57218 Share on other sites More sharing options...
bettyatolive Posted July 13, 2006 Author Share Posted July 13, 2006 I cannot go on comparing each and every value.. becouse i have some 75 controls on my page. Here i'm sending you the form.[code]<patTemplate:tmpl name="AgentActivityForm"><script language="javascript">function validate(){ var agree=confirm("Are you sure you wish to Continue"); if (agree) return true ; else return false ;}</script><script language=javascript src="../include/calendar.js"></script> <td width="475" valign="top" class="lline"><!-- InstanceBeginEditable name="mainbody" --> <table width="430" border="0" cellpadding="0" cellspacing="0"> <tr> <td height="40" valign="top"><p align="left"><img src="images/reportsActSubHD.gif" alt="Activity Submission Report" width="354" height="22" /></p></td> </tr> <tr> <td height="75" valign="top"><table width="200" border="0" align="right" cellpadding="0" cellspacing="0"> <tr> <td width="145" valign="bottom"><p><a href="aa_enquiryForm.php">Enquiries</a> | <a href="aa_expenseForm.php">Expenses</a> </p> </td> <td width="55"><a href="aa_reports.php"><img src="../icons1/reports_Icon.gif" alt="reports" width="50" height="58" border="0" /></a></td> </tr> </table> <p> </p> </td> </tr> <tr> <td> <form name="frm_ActivityReport" method="post" action="aa_activityForm.php" onSubmit='return validate();'> <table width="425" border="0" cellpadding="0" cellspacing="0"> <tr> <td colspan="2" bgcolor="#CCCCCC"><img src="../nav/spacer.gif" alt=" " width="1" height="1" /></td> </tr> <tr> <td height="50" colspan="2"><h2>Follow-up of Enquiries and initial application: </h2> <span class="tabletxt10">a) List of enquirers to whom information packets were sent during this month.</span></td> </tr> <tr> <td colspan="2"><table width="424" border="0" cellspacing="0" cellpadding="2"> <tr> <td width="101" height="15" bgcolor="#B5DEFF" class="tabletxt10"><strong>Name</strong></td> <td width="100" height="15" bgcolor="#B5DEFF" class="tabletxt10"><strong>Profession</strong></td> <td width="77" height="15" bgcolor="#B5DEFF" class="tabletxt10"><strong>(P/OT) </strong></td> <td width="130" height="15" bgcolor="#B5DEFF" class="tabletxt10"><strong>Country</strong></td> </tr> <tr> <td bgcolor="#E8E8E8"> <input name="Name1" type="text" class="tabletxt10" id="Name" size="16" maxlength="25" /></td> <td bgcolor="#E8E8E8"> <input name="Profession1" type="text" class="tabletxt10" id="Profession" maxlength="35" size="16" /></td> <td bgcolor="#E8E8E8"> <select name="Interest1" class="tabletxt10" id="Interest"> <option value="">--Interest--</option> <option value="Partner">Partner</option> <option value="On-Track">On-Track</option> </select> </td> <td bgcolor="#E8E8E8"><select name="Country1" class="tabletxt10" id="Country"> <option value="">--Select Country--</option> <option value="Afghanistan">Afghanistan</option> <option value="Bangladesh">Bangladesh</option> <option value="CAR">CAR</option> <option value="Chian Mai">Chian Mai</option> <option value="Cyprus">Cyprus</option> <option value="Egypt">Egypt</option> <option value="Gulf">Gulf</option> <option value="India">India</option> <option value="Jordan">Jordan</option> <option value="Lebanon">Lebanon</option> <option value="Malaysia">Malaysia</option> <option value="Mongolia">Mongolia</option> <option value="Nepal">Nepal</option> <option value="NAT">NAT</option> <option value="NAS">NAS</option> <option value="Pakistan">Pakistan</option> <option value="Pen Asia">Pen Asia</option> <option value="Project Blue">Project Blue</option> <option value="Proj. Thanksgiving">Proj. Thanksgiving</option> <option value="Red Sea">Red Sea</option> <option value="Other">Other</option> </select> </td> </tr> <tr> <td bgcolor="#E8E8E8"><input name="Name2" type="text" class="tabletxt10" id="Name" size="16" /></td> <td bgcolor="#E8E8E8"><input name="Profession2" type="text" class="tabletxt10" id="Profession" size="16" /></td> <td bgcolor="#E8E8E8"><select name="Interest2" class="tabletxt10" id="select"> <option value="">--Interest--</option> <option value="Partner">Partner</option> <option value="On-Track">On-Track</option> </select></td> <td bgcolor="#E8E8E8"><select name="Country2" class="tabletxt10" id="select5"> <option value="">--Select Country--</option> <option value="Afghanistan">Afghanistan</option> <option value="Bangladesh">Bangladesh</option> <option value="CAR">CAR</option> <option value="Chian Mai">Chian Mai</option> <option value="Cyprus">Cyprus</option> <option value="Egypt">Egypt</option> <option value="Gulf">Gulf</option> <option value="India">India</option> <option value="Jordan">Jordan</option> <option value="Lebanon">Lebanon</option> <option value="Malaysia">Malaysia</option> <option value="Mongolia">Mongolia</option> <option value="Nepal">Nepal</option> <option value="NAT">NAT</option> <option value="NAS">NAS</option> <option value="Pakistan">Pakistan</option> <option value="Pen Asia">Pen Asia</option> <option value="Project Blue">Project Blue</option> <option value="Proj. Thanksgiving">Proj. Thanksgiving</option> <option value="Red Sea">Red Sea</option> <option value="Other">Other</option> </select></td> </tr> <tr> <td bgcolor="#E8E8E8"><input name="Name3" type="text" class="tabletxt10" id="Name" size="16" maxlength="25" /></td> <td bgcolor="#E8E8E8"><input name="Profession3" type="text" class="tabletxt10" id="Profession" size="16" maxlength="35" /></td> <td bgcolor="#E8E8E8"><select name="Interest3" class="tabletxt10" id="select2"> <option value="">--Interest--</option> <option value="Partner">Partner</option> <option value="On-Track">On-Track</option> </select></td> <td bgcolor="#E8E8E8"><select name="Country3" class="tabletxt10" id="select6"> <option value="">--Select Country--</option> <option value="Afghanistan">Afghanistan</option> <option value="Bangladesh">Bangladesh</option> <option value="CAR">CAR</option> <option value="Chian Mai">Chian Mai</option> <option value="Cyprus">Cyprus</option> <option value="Egypt">Egypt</option> <option value="Gulf">Gulf</option> <option value="India">India</option> <option value="Jordan">Jordan</option> <option value="Lebanon">Lebanon</option> <option value="Malaysia">Malaysia</option> <option value="Mongolia">Mongolia</option> <option value="Nepal">Nepal</option> <option value="NAT">NAT</option> <option value="NAS">NAS</option> <option value="Pakistan">Pakistan</option> <option value="Pen Asia">Pen Asia</option> <option value="Project Blue">Project Blue</option> <option value="Proj. Thanksgiving">Proj. Thanksgiving</option> <option value="Red Sea">Red Sea</option> <option value="Other">Other</option> </select></td> </tr> <tr> <td bgcolor="#E8E8E8"><input name="Name4" type="text" class="tabletxt10" id="Name" size="16" maxlength="25"/></td> <td bgcolor="#E8E8E8"><input name="Profession4" type="text" class="tabletxt10" id="Profession" size="16" maxlength="35" /></td> <td bgcolor="#E8E8E8"><select name="Interest4" class="tabletxt10" id="select3"> <option value="">--Interest--</option> <option value="Partner">Partner</option> <option value="On-Track">On-Track</option> </select></td> <td bgcolor="#E8E8E8"><select name="Country4" class="tabletxt10" id="select7"> <option value="">--Select Country--</option> <option value="Afghanistan">Afghanistan</option> <option value="Bangladesh">Bangladesh</option> <option value="CAR">CAR</option> <option value="Chian Mai">Chian Mai</option> <option value="Cyprus">Cyprus</option> <option value="Egypt">Egypt</option> <option value="Gulf">Gulf</option> <option value="India">India</option> <option value="Jordan">Jordan</option> <option value="Lebanon">Lebanon</option> <option value="Malaysia">Malaysia</option> <option value="Mongolia">Mongolia</option> <option value="Nepal">Nepal</option> <option value="NAT">NAT</option> <option value="NAS">NAS</option> <option value="Pakistan">Pakistan</option> <option value="Pen Asia">Pen Asia</option> <option value="Project Blue">Project Blue</option> <option value="Proj. Thanksgiving">Proj. Thanksgiving</option> <option value="Red Sea">Red Sea</option> <option value="Other">Other</option> </select></td> </tr> <tr> <td bgcolor="#E8E8E8"><input name="Name5" type="text" class="tabletxt10" id="Name" size="16" maxlength="25" /></td> <td bgcolor="#E8E8E8"><input name="Profession5" type="text" class="tabletxt10" id="Profession" size="16" maxlength="35" /></td> <td bgcolor="#E8E8E8"><select name="Interest5" class="tabletxt10" id="select4"> <option value="">--Interest--</option> <option value="Partner">Partner</option> <option value="On-Track">On-Track</option> </select></td> <td bgcolor="#E8E8E8"><select name="Country5" class="tabletxt10" id="select8"> <option value="">--Select Country--</option> <option value="Afghanistan">Afghanistan</option> <option value="Bangladesh">Bangladesh</option> <option value="CAR">CAR</option> <option value="Chian Mai">Chian Mai</option> <option value="Cyprus">Cyprus</option> <option value="Egypt">Egypt</option> <option value="Gulf">Gulf</option> <option value="India">India</option> <option value="Jordan">Jordan</option> <option value="Lebanon">Lebanon</option> <option value="Malaysia">Malaysia</option> <option value="Mongolia">Mongolia</option> <option value="Nepal">Nepal</option> <option value="NAT">NAT</option> <option value="NAS">NAS</option> <option value="Pakistan">Pakistan</option> <option value="Pen Asia">Pen Asia</option> <option value="Project Blue">Project Blue</option> <option value="Proj. Thanksgiving">Proj. Thanksgiving</option> <option value="Red Sea">Red Sea</option> <option value="Other">Other</option> </select></td> </tr> </table></td> </tr> <tr> <td height="30" colspan="2" class="tabletxt10">b) List names of Partner and On-Track application received this month. </td> </tr> <tr> <td colspan="2"><table width="424" border="0" cellspacing="0" cellpadding="2"> <tr> <td width="102" height="15" bgcolor="#B5DEFF" class="tabletxt10"><strong>Name</strong></td> <td width="85" height="15" bgcolor="#B5DEFF" class="tabletxt10"><strong>(P/OT) </strong></td> <td width="225" height="15" bgcolor="#B5DEFF" class="tabletxt10"><strong>Comments</strong> (timeframe, country) </td> </tr> <tr> <td bgcolor="#E8E8E8"><input name="NamePOT1" maxlength="25"type="text" class="tabletxt10" id="Name1" size="16" /></td> <td bgcolor="#E8E8E8"><select name="POT1" class="tabletxt10" id="select9"> <option value="">--Select--</option> <option value="Partner">Partner</option> <option value="On Track">On Track</option></select></td> <td bgcolor="#E8E8E8"><textarea name="Comment1" cols="35" class="tabletxt10" id="Comment1"></textarea></td> </tr> <tr> <td bgcolor="#E8E8E8"><input name="NamePOT2" maxlength="25" type="text" class="tabletxt10" id="Name2" size="16" /></td> <td bgcolor="#E8E8E8"><select name="POT2" class="tabletxt10" id="select11"> <option value="">--Select--</option> <option value="Partner">Partner</option> <option value="On Track">On Track</option></select></td> <td bgcolor="#E8E8E8"><textarea name="Comment2" cols="35" class="tabletxt10" id="Comment2"></textarea></td> </tr> <tr> <td bgcolor="#E8E8E8"><input name="NamePOT3" maxlength="25" type="text" class="tabletxt10" id="Name3" size="16" /></td> <td bgcolor="#E8E8E8"><select name="POT3" class="tabletxt10" id="select13"> <option value="">--Select--</option> <option value="Partner">Partner</option> <option value="On Track">On Track</option> </select></td> <td bgcolor="#E8E8E8"><textarea name="Comment3" cols="35'" class="tabletxt10" id="Comment3"></textarea></td> </tr> <tr> <td bgcolor="#E8E8E8"><input name="NamePOT4" maxlength="25" type="text" class="tabletxt10" id="Name4" size="16" /></td> <td bgcolor="#E8E8E8"><select name="POT4" class="tabletxt10" id="select15"> <option value="">--Select--</option> <option value="Partner">Partner</option> <option value="On Track">On Track</option> </select></td> <td bgcolor="#E8E8E8"><textarea name="Comment4" cols="35" class="tabletxt10" id="Comment4"></textarea></td> </tr> <tr> <td bgcolor="#E8E8E8"><input name="NamePOT5" maxlength="25" type="text" class="tabletxt10" id="Name5" size="16" /></td> <td bgcolor="#E8E8E8"><select name="POT5" class="tabletxt10" id="select17"> <option value="">--Select--</option> <option value="Partner">Partner</option> <option value="On Track">On Track</option></select></td> <td bgcolor="#E8E8E8"><textarea name="Comment5" cols="35" class="tabletxt10" id="Comment5"></textarea></td> </tr> </table></td> </tr> <tr> <td height="40" colspan="2"><h2>Application Processing during this month: </h2></td> </tr> <tr> <td colspan="2"><table width="424" border="0" cellspacing="0" cellpadding="2"> <tr> <td width="148" height="15" bgcolor="#B5DEFF" class="tabletxt10"><strong>Name</strong></td> <td width="86" height="15" bgcolor="#B5DEFF" class="tabletxt10"><strong>P/OT</strong></td> <td width="85" height="15" bgcolor="#B5DEFF" class="tabletxt10"><strong>Application</strong></td> <td width="89" height="15" bgcolor="#B5DEFF" class="tabletxt10"><strong>Interview</strong></td> </tr> <tr> <td bgcolor="#E8E8E8"><input name="NameAP1"maxlength="25" type="text" class="tabletxt10" id="Name1" size="22" /></td> <td bgcolor="#E8E8E8"><select name="PT1" class="tabletxt10" id="select12"> <option value="">--Select--</option> <option value="Partner">Partner</option> <option value="On Track">On Track</option> </select></td> <td bgcolor="#E8E8E8"><select name="Application1" class="tabletxt10" id="select10"> <option value="">--Select--</option> <option value="On Track">On Track</option> <option value="P Step #1">P Step #1</option> <option value="P Step #2">P Step #2</option> </select> </td> <td bgcolor="#E8E8E8"><select name="Interview1" class="tabletxt10" id="select24"> <option value="">--Select--</option> <option value="On Track">On Track</option> <option value="P Step #1">P Step #1</option> <option value="P Step #2">P Step #2</option> </select></td> </tr> <tr> <td bgcolor="#E8E8E8"><input name="NameAP2" maxlength="25" type="text" class="tabletxt10" id="Name2" size="22" /></td> <td bgcolor="#E8E8E8"><select name="PT2" class="tabletxt10" id="select16"> <option value="">--Select--</option> <option value="Partner">Partner</option> <option value="On Track">On Track</option> </select></td> <td bgcolor="#E8E8E8"><select name="Application2" class="tabletxt10" id="select14"> <option value="">--Select--</option> <option value="On Track">On Track</option> <option value="P Step #1">P Step #1</option> <option value="P Step #2">P Step #2</option> </select></td> <td bgcolor="#E8E8E8"><select name="Interview2" class="tabletxt10" id="select25"> <option value="">--Select--</option> <option value="On Track">On Track</option> <option value="P Step #1">P Step #1</option> <option value="P Step #2">P Step #2</option> </select></td> </tr> <tr> <td bgcolor="#E8E8E8"><input name="NameAP3" maxlength="25" type="text" class="tabletxt10" id="Name3" size="22" /></td> <td bgcolor="#E8E8E8"><select name="PT3" class="tabletxt10" id="select18"> <option value="">--Select--</option> <option value="Partner">Partner</option> <option value="On Track">On Track</option> </select></td> <td bgcolor="#E8E8E8"><select name="Application3" class="tabletxt10" id="select19"> <option value="">--Select--</option> <option value="On Track">On Track</option> <option value="P Step #1">P Step #1</option> <option value="P Step #2">P Step #2</option> </select></td> <td bgcolor="#E8E8E8"><select name="Interview3" class="tabletxt10" id="select26"> <option value="">--Select--</option> <option value="On Track">On Track</option> <option value="P Step #1">P Step #1</option> <option value="P Step #2">P Step #2</option> </select></td> </tr> <tr> <td bgcolor="#E8E8E8"><input name="NameAP4" maxlength="25" type="text" class="tabletxt10" id="Name4" size="22" /></td> <td bgcolor="#E8E8E8"><select name="PT4" class="tabletxt10" id="select21"> <option value="">--Select--</option> <option value="Partner">Partner</option> <option value="On Track">On Track</option> </select></td> <td bgcolor="#E8E8E8"><select name="Application4" class="tabletxt10" id="select20"> <option value="">--Select--</option> <option value="On Track">On Track</option> <option value="P Step #1">P Step #1</option> <option value="P Step #2">P Step #2</option> </select></td> <td bgcolor="#E8E8E8"><select name="Interview4" class="tabletxt10" id="select27"> <option value="">--Select--</option> <option value="On Track">On Track</option> <option value="P Step #1">P Step #1</option> <option value="P Step #2">P Step #2</option> </select></td> </tr> <tr> <td bgcolor="#E8E8E8"><input name="NameAP5" maxlength="25" type="text" class="tabletxt10" id="Name5" size="22" /></td> <td bgcolor="#E8E8E8"><select name="PT5" class="tabletxt10" id="select23"> <option value="">--Select--</option> <option value="Partner">Partner</option> <option value="On Track">On Track</option> </select></td> <td bgcolor="#E8E8E8"><select name="Application5" class="tabletxt10" id="select22"> <option value="">--Select--</option> &nbs Quote Link to comment https://forums.phpfreaks.com/topic/14465-submitting-a-form/#findComment-57220 Share on other sites More sharing options...
brown2005 Posted July 13, 2006 Share Posted July 13, 2006 well thats me out then, cause i don't know Quote Link to comment https://forums.phpfreaks.com/topic/14465-submitting-a-form/#findComment-57223 Share on other sites More sharing options...
GingerRobot Posted July 13, 2006 Share Posted July 13, 2006 The only way i could think of doing this would be to check every item in the POST array:[code]<?phpforeach($_POST as $check){ if (empty($check) && $check !="submit")//the name of your submit button { $num++;}}if($num != 0){ echo "all fields are empty";}else{ echo "not all fields are empty";}?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/14465-submitting-a-form/#findComment-57228 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.