kvigor Posted May 10, 2007 Share Posted May 10, 2007 $label_array = array ("conName" => "Consumer Name", "conAddress" => "Consumer Address", "conCity" => "Consumer City", "conState" => "Consumer State", "conZip" => "Consumer Zip Code", "conPhone" => "Consumer Phone", "schName" => "School Name", "schAddress" => "School Address", "schCity" => "School City", "schState" => "School State", "schZip" => "School Zip Code", "strName" => "Store Name", "strCity" => "Store City", "strState" => "Store State"); //check data fields for correct data foreach($_POST as $field => $value) { if ($value == "") { $blank_array[$field] = "blank"; } } if(@sizeof($blank_array) > 0) { echo "<div class='ermess1'>*You didn't fill in one or more required fields.</div>"; foreach($blank_array as $field => $value) { echo " <div>{$label_array[$field]}</div>"; } } else { echo "Thank You for Entering"; } //====================================================================== foreach($_POST as $field => $value) { if (!ereg("^[0-9]{5}(\-[0-9]{4})?$",$_POST['conState'])) // I only want to check this variable for now // even when I insert $value as the variable output is the same { $format[$field] = "bad"; } } if(@sizeof($format) > 0) { echo "<div class='ermess1'>*The following fields looks to have the wrong format:</div>"; foreach($format as $field => $value) { echo " <div>{$label_array[$field]}</div>"; } } //This is the output when I hit submit: //begin output *You didn't fill in one or more required fields. Store State //I left this field blank so it’s working right *The following fields looks to have the wrong format: //Below out is where it's wrong it should only return the Consumer Zip field not all of them. Consumer Name Consumer Address Consumer City Consumer State Consumer Zip Code Consumer Phone School Name School Address School City School State School Zip Code Store Name Store City Store State Notice: Undefined index: submit in C:\htdocs\folder\folder.php on line 75 // don’t know why I’m getting this notice Quote Link to comment https://forums.phpfreaks.com/topic/50848-form-issues-i-know-im-missing-something-simple/ Share on other sites More sharing options...
MadTechie Posted May 10, 2007 Share Posted May 10, 2007 can you post the form code as well please Quote Link to comment https://forums.phpfreaks.com/topic/50848-form-issues-i-know-im-missing-something-simple/#findComment-250078 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.