Page 1 of 1

[SOLVED] Am I overlooking the obvious?

Posted: Tue Aug 03, 2004 3:33 am
by John Cartwright

Code: Select all

<?php
		if (!empty($_POST["Submit"]))
		{
			$fields   = array($_POST["lastname"],$_POST["email"],$_POST["email2"]);
						
			foreach ($fields as $field)
			{
echo $field;			
	if (!empty($field))
				{
					$fnum += 1;					
				}
				else
				{
					$fielderror[] = "You are missing". $field;
				}
			}
?>
For some reasons $field will never get printed. !?

Posted: Tue Aug 03, 2004 3:39 am
by markl999
Is $_POST["Submit"] set/not empty?
What does a var_dump($_POST); show?
Sure it's not 'submit' instead of 'Submit'?
:o

Posted: Tue Aug 03, 2004 3:42 am
by John Cartwright
oh no the rest is working perfectly...

when i output the array $fielderror[] its:

you are missing
you are missing
you are missing

Posted: Tue Aug 03, 2004 3:44 am
by markl999
Ah, that's your logic...take another look at it:

Code: Select all

if (!empty($field))
{
    $fnum += 1;               
}
else
{
    $fielderror[] = "You are missing". $field;
}
So you're saying if $field is NOT empty then do $fnum += 1; .. otherwise, if it IS empty then add the message to the array :p

Posted: Tue Aug 03, 2004 3:47 am
by John Cartwright
rofl @ me... its 4:46 in the morning.. sorry.

Posted: Tue Aug 03, 2004 6:10 am
by fresh
that's not an exscuse, ... ok it is :)

Posted: Tue Aug 03, 2004 6:28 am
by Grim...
Am I overlooking the obvious?
Yes ;)