I shouldn't really be helping because others have pointed out that this appears to be a script designed to brute force login to a website. But heres some pointers since you already have your code up and running...

1) You probably don't want to keep setting the referrer header per iteration.