DBookatay Posted May 10, 2006 Share Posted May 10, 2006 This is a very new-B question, but can someone show me a working code that will return an error message if required fields are not filled in?I built a 2 part form, new.php and order.php, and when someone enters info into new.php it is passed along to order.php as hidden fields, then instered into my db. What I now need to do is make the form fields required, but cant get that hang of it. And I have tried and tried and tried...If someone can show me an example I would REALLY apprechiate it.[code]<?php include ('../common/include/header.php'); include_once ("../auth.php"); include_once ("../authconfig.php"); include_once ("../check.php");?> <td class="lftNavHldr" rowspan="2"> <?php include ('../common/include/lftNav_Vendor.php'); ?> </td> <td class="mainNavBlank">Logged in as: <span class="user"><? echo $USERNAME; ?></span></td></tr> <tr> <td class="main"> <table> <tr><td class="hdr">Post A New Add</td></tr> <tr> <td class="index"> <div class="form"> <form name="form1" method="post" action="order.php"> <table> <tr> <td>Primary Trade Channel:</td> <td rowspan="2"><img src="../common/images/spacer.gif" width="20" height="1" /></td> <td>Secondary Trade Channel:</td> </tr> <tr> <td class="inptHldr"> <select class="DropDown" name="Primary_Trade"> <option></option> <option value="Accessories">Accessories</option> <option value="Automotive">Automotive</option> <option value="Beauty">Beauty Supplies</option> <option value="Bedding">Bedding</option> <option value="Computer">Computer/Software/Peripherals</option> <option value="Electronics">Consumer Electronics</option> <option value="Fashion">Fashion</option> <option value="Food">Food & Drug</option> <option value="Furniture">Furniture</option> <option value="Garden">Garden</option> <option value="Giftware">Giftware</option> <option value="Healthcare">Healthcare/OTC</option> <option value="Doctor">Healthcare/Doctor/Detailing/Hospital</option> <option value="Home">Home Improvement</option> <option value="Housewares">Housewares</option> <option value="Jewelry">Jewelry</option> <option value="Luggage">Luggage</option> <option value="Outdoor">Outdoor</option> <option value="Pet">Pet Supply</option> <option value="Security">Security</option> <option value="Sports">Sporting Goods</option> <option value="Travel">Travel</option> </select> </td> <td class="inptHldr"> <select class="DropDown" name="Secondary_Trade"> <option></option> <option value="Accessories">Accessories</option> <option value="Automotive">Automotive</option> <option value="Beauty">Beauty Supplies</option> <option value="Bedding">Bedding</option> <option value="Computer">Computer/Software/Peripherals</option> <option value="Electronics">Consumer Electronics</option> <option value="Fashion">Fashion</option> <option value="Food">Food & Drug</option> <option value="Furniture">Furniture</option> <option value="Garden">Garden</option> <option value="Giftware">Giftware</option> <option value="Healthcare">Healthcare/OTC</option> <option value="Doctor">Healthcare/Doctor/Detailing/Hospital</option> <option value="Home">Home Improvement</option> <option value="Housewares">Housewares</option> <option value="Jewelry">Jewelry</option> <option value="Luggage">Luggage</option> <option value="Outdoor">Outdoor</option> <option value="Pet">Pet Supply</option> <option value="Security">Security</option> <option value="Sports">Sporting Goods</option> <option value="Travel">Travel</option> </select> </td> </tr> <tr><td colspan="3">Product Title:</td></tr> <tr><td class="inptHldr" colspan="3"><input class="Input" type="text" name="Product_Title" size="78" maxlength="255" /></td></tr> <tr><td colspan="3">Description of product:</td></tr> <tr><td class="inptHldr" colspan="3"><textarea name="Product_Description" class="TextArea" rows="9" cols="80"></textarea></td></tr> <tr><td colspan="3">Description of Engagement:</td></tr> <tr><td class="inptHldr" colspan="3"><textarea name="Engagement_Description" class="TextArea" rows="5" cols="80"></textarea></td></tr> <tr> <td colspan="5"> <table> <tr> <td>Contact Name:</td> <td rowspan="2"><img src="../images/spacer.gif" width="20" height="1" /></td> <td>Title:</td> </tr> <tr> <td class="inptHldr"><input class="Input" type="text" name="Contact_Name" size="33" maxlength="100" /></td> <td class="inptHldr"><input class="Input" type="text" name="Contact_Title" size="33" maxlength="100" /></td> </tr> </table> </td> </tr> <tr><td class="dots" colspan="3"><image src="../images/spacer.gif" height="18" width="1" /></td></tr> <tr><td class="btnHldr" colspan="3"><input type="image" src="../images/BTN_Go.gif" name="submit" border="0" /></td></tr> </table> </form> </div> </td> </tr> </table> </td> </tr> </table><?php include ('../common/include/footer.php');?>[/code] Link to comment https://forums.phpfreaks.com/topic/9447-help-with-form-validation/ Share on other sites More sharing options...
Guest askjames01 Posted May 10, 2006 Share Posted May 10, 2006 [img src=\"style_emoticons/[#EMO_DIR#]/wink.gif\" style=\"vertical-align:middle\" emoid=\":wink:\" border=\"0\" alt=\"wink.gif\" /] here study this link --> [a href=\"http://www.php-mysql-tutorial.com/form-validation-with-php.php\" target=\"_blank\"]The validation form.[/a]GOOD LUCK! Link to comment https://forums.phpfreaks.com/topic/9447-help-with-form-validation/#findComment-34836 Share on other sites More sharing options...
DBookatay Posted May 10, 2006 Author Share Posted May 10, 2006 [!--quoteo(post=372839:date=May 10 2006, 02:55 AM:name=askjames01)--][div class=\'quotetop\']QUOTE(askjames01 @ May 10 2006, 02:55 AM) [snapback]372839[/snapback][/div][div class=\'quotemain\'][!--quotec--][img src=\"style_emoticons/[#EMO_DIR#]/wink.gif\" style=\"vertical-align:middle\" emoid=\":wink:\" border=\"0\" alt=\"wink.gif\" /] here study this link --> [a href=\"http://www.php-mysql-tutorial.com/form-validation-with-php.php\" target=\"_blank\"]The validation form.[/a]GOOD LUCK![/quote]I'd like to do it via PHP not java scripts....Thanks anyway though! Link to comment https://forums.phpfreaks.com/topic/9447-help-with-form-validation/#findComment-34837 Share on other sites More sharing options...
GarethMarijt Posted May 10, 2006 Share Posted May 10, 2006 [!--quoteo(post=372840:date=May 10 2006, 07:58 AM:name=DBookatay)--][div class=\'quotetop\']QUOTE(DBookatay @ May 10 2006, 07:58 AM) [snapback]372840[/snapback][/div][div class=\'quotemain\'][!--quotec--]I'd like to do it via PHP not java scripts....Thanks anyway though![/quote]I am a bit new to this so please make allowances...I had a similar problem which I resolved by merging the two pages:Please note - this not the actual code, rather a summary of the method<?phpfunction validated(){ if (isset($_REQUEST['input_callref'])) //and any other checks you need return true; else return false;}if (validated()){ //Contents of order.php} else{ ?> <form method="post" name="data_capture" action="<?php echo $_SERVER['PHP_SELF'] ?>" <!-- Contents of new.php e.g. --> <input type="text" name="input_callref" size="15" tabindex="1"> </form> <?php}?> Link to comment https://forums.phpfreaks.com/topic/9447-help-with-form-validation/#findComment-34897 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.