OH man, thats the ticket. I didnt even think about checking the $_POST["email"] == "email" and then running the preg_match. I assumed that it evaluate the end of the preg_match statement and see $_POST["email"]
I appreciate your time... Sincerely, Dan ----- Original Message ----- From: "Ralph" <[EMAIL PROTECTED]> To: "'Daniel J. Rychlik'" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]> Sent: Friday, May 30, 2003 4:41 PM Subject: RE: [PHP] preg_match array question > foreach ($_POST as $key=>$value) { > > if (empty($value)) { > error_message[] = "$key :: Missing Data<br/>"; > } > > // if email field, perform email validation > if($_POST[$key] == 'email') > if (!preg_match('/([a-z0-9\-\.\#\:[EMAIL PROTECTED])/i', > $_POST[$key])) { > error_message[] = $value . " is not a valid address.<br/>"; } > } > > // etc.......... > > } > > // check for error message > if(!empty($error_message)){ > $c = count($error_message); > for($i = 0; $i < $c; $i++){ > echo $error_message[$i]; > } > } else { > // no error found > } > > -----Original Message----- > From: Daniel J. Rychlik [mailto:[EMAIL PROTECTED] > Sent: Friday, May 30, 2003 1:04 PM > To: Ralph; [EMAIL PROTECTED] > Subject: Re: [PHP] preg_match array question > > perhaps I am misunderstanding... I have snipit of my foreach. I have a > preg_match that checks for a valid email address. basically it just > checks > for an @ and a . When I place this in my loop all of the keys are > evaluated, so hence the name key is evaluated and thrown error because > of > the check. > > To remedy this problem I took it out of the loop and it worked fine. > Ultimately I would love to keep it in the loop and throw checks for > certain > fields, but syntaxtually it doesnt work for me. Any Suggestions ? > > > foreach ($_POST as $key=>$value) { # Begin Foreach loop > > > if (empty($value)) { # Begin If > echo "$key :: Missing Data<br/>"; > > if (!preg_match('/([a-z0-9\-\.\#\:[EMAIL PROTECTED])/i', > $_POST["eaddy"])) > {echo $_POST["eaddy"]," is not a valid address.<br/>"; } > } # End if > > else { echo "$key, ->Ok<br/>";} > > } # End Foreach > > > ----- Original Message ----- > From: "Ralph" <[EMAIL PROTECTED]> > To: "'Daniel J. Rychlik'" <[EMAIL PROTECTED]>; > <[EMAIL PROTECTED]> > Sent: Friday, May 30, 2003 2:42 PM > Subject: RE: [PHP] preg_match array question > > > > Not sure if I'm misunderstanding, but I know that foreach() will do > > this. > > > > -----Original Message----- > > From: Daniel J. Rychlik [mailto:[EMAIL PROTECTED] > > Sent: Friday, May 30, 2003 11:58 AM > > To: Ralph; [EMAIL PROTECTED] > > Subject: Re: [PHP] preg_match array question > > > > The problem is, that I have multiple fields and what I am trying to do > > is > > check each field to make sure I get the data that I need and not some > > crap, > > like letters in a number field or a <script> tag in a field. Things > of > > this > > sort. The foreach loop wont work for me in this instance because Im > > checking for proper input. > > > > I can write multiple elseif statements to check each field but alas, > > this is > > not optimal. I may go ahead and write this to get it done and then go > > back > > and put it to the write board.... > > > > > > > > > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php