[snip] and changing the if/else to if($retval) { The $retval variable is always set to either true or false. [/snip] It may be, but in the statement above it ALWAYS evaluates to TRUE, you must test for the value; if(FALSE === $retval)