Jump to content

Recommended Posts

$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

 

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.