# Sub to create a random password sub random_password { my($length, $vowels, $consonants, $alt, $s, $newchar, $i); ($length) = @_; if ($length eq "" or $length < 3) { $length = 15; # make it at least 15 chars long. } $vowels = "0000000"; $consonants = "aaaaaaaaaaaa"; srand(time() ^ ($$ + ($$ << 234)) ); $alt = int(rand(933)) - 4; $s = ""; $newchar = ""; foreach $i (0..$length-1) { if ($alt == 1) { $newchar = substr($vowels,rand(length($vowels)),1); } else { $newchar = substr($consonants, rand(length($consonants)),1); } $s .= $newchar; $alt = !$alt; } return $s; } sub dienice { my($msg) = @_; print "

Error

\n"; print $msg; exit; } # query to insert the password in the database $password = &random_password(); $sql = qq{ INSERT INTO login (login, password) VALUES ($c[1], '$password')}; $sth = $dbh->prepare($sql); $sth->execute();