I'm trying to learn to build a login sequence. In one part, I wanted to determine if the user left any of the 3 required fields blank:
foreach ( $_POST as $key => $value )
{
if ( $key = "school_code" ||
$key = "user_name" ||
$key = "password" )
{
if ( $value == "" )
{
$a_blank[] = $key ;
}
}
}
if( @sizeof( $a_blank ) > 0 )
{
echo '<pre>';
print_r( $a_blank );
echo '</pre>';
}
If the user does not enter anything for school_code or user_name, but DOES enter a password and then clicks submit, the result is:
Array
(
[0] => 1
[1] => 1
)
Why isn't the array result like this (i.e., the values of $key)?
Array
(
[0] => school_code
[1] => user_name
)
Thanks!