I haven't looked too closely at it, but this line:
open (storedata, ">$data_directory/form1/$count.txt") or Common::error("unable to create $count.txt");
Will overwrite files every time. Change it to this:
open (storedata, ">>$data_directory/form1/$count.txt") or Common::error("unable to create $count.txt");
to append, which probably has it's own set of problems.
A better approach would be to understand the password hashing, and use that in album.pl checking.
Can you find out (IPB support forums maybe?) what they use to hash passwords in the DB?