Have a look around for error messages in your logs etc. (and consider using the DBI 'RaiseError' etc.), but I suspect this might be to do with quoting in your SQL statements. Try using $dbh->quote() something like this...
my $query = "UPDATE staff
SET password=".$dbh->quote($FORM{'newpassword'}.
" WHERE ".$dbh->quote($FORM{'name'}).
" =". $dbh->quote($record{'login'});