PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
John Cartwright
Site Admin
Posts: 11470 Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:
Post
by John Cartwright » Tue Aug 03, 2004 3:33 am
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. !?
markl999
DevNet Resident
Posts: 1972 Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)
Post
by markl999 » Tue Aug 03, 2004 3:39 am
Is $_POST["Submit"] set/not empty?
What does a var_dump($_POST); show?
Sure it's not 'submit' instead of 'Submit'?
John Cartwright
Site Admin
Posts: 11470 Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:
Post
by John Cartwright » Tue Aug 03, 2004 3:42 am
oh no the rest is working perfectly...
when i output the array $fielderror[] its:
you are missing
you are missing
you are missing
markl999
DevNet Resident
Posts: 1972 Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)
Post
by markl999 » Tue Aug 03, 2004 3:44 am
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
John Cartwright
Site Admin
Posts: 11470 Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:
Post
by John Cartwright » Tue Aug 03, 2004 3:47 am
rofl @ me... its 4:46 in the morning.. sorry.
fresh
Forum Contributor
Posts: 259 Joined: Mon Jun 14, 2004 10:39 am
Location: Amerika
Post
by fresh » Tue Aug 03, 2004 6:10 am
that's not an exscuse, ... ok it is
Grim...
DevNet Resident
Posts: 1445 Joined: Tue May 18, 2004 5:32 am
Location: London, UK
Post
by Grim... » Tue Aug 03, 2004 6:28 am
Am I overlooking the obvious?
Yes