Nenad wrote: : I use something like this
Humor me and do this exactly. Show the list what the result is. Change passwords where appropriate. I am curious about whether this part works. Let's make sure it does before we move on to checking for a valid user. use strict; use warnings; use DBI; use Data::Dumper 'Dumper'; my %provera = provera_korisnika(); print Dumper \%provera; sub provera_korisnika { my $dbh = DBI->connect( "DBI:mysql:evidencija", 'root', '', { RaiseError => 1, AutoCommit => 0, } ) || die "Database connection not made: $DBI::errstr"; my $sql = qq{ SELECT user, pass FROM login }; my $sth = $dbh->prepare( $sql ); $sth->execute(); my( $user, $pass ); $sth->bind_columns( undef, \$user, \$pass ); my %provera; while( $sth->fetch() ) { $provera{ $user } = $pass; } return %provera; } __END__ : sub provera_korisnika #Proveravam korisnicko ime i lozinku : { : $ime = $user->get_text; #this method get text from entry : $lozinka = $pass->get_text; #this to This is a really really bad practice. $user and $pass have not been passed into this subroutine. If you want help from this list, you'll need to stop writing this kind of code. Everything must pass in and pass out of the subroutine explicitly. No shortcuts. I you do not understand this, we need to start a new thread on writing subroutines. Once you can write good subroutines you will never write like this again. : $dbh = DBI->connect( : "DBI:mysql:evidencija", : 'root', '', { : RaiseError =>1, : AutoCommit =>0 } : ) || die "Database connection ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ What's with all this space? Edit your email better than this. Four spaces would be sufficient. Have your editor convert tabs to spaces before pasting the code to your message. Don't rely on the email program to wrap long lines. Wrap long lines yourself. : my $sql = qq{ SELECT user, pass FROM login }; : my $sth = $dbh->prepare( $sql ); : $sth->execute(); : : my( $user, $pass ); : $sth->bind_columns( undef, \$user, \$pass ); : : while( $sth->fetch() ) : { : foreach($user) : { Most looping is done over a list or array, not a single scalar. This is okay if you realize that $user is now aliased inside $_. You obviously don't know that. So you can skip the loop completely. : if( $user eq $ime) : { : print "$user, $ime\n"; #what if OK : } : else { Gtk2->main_quit; } #what if wrong : } : } : } : : I want if user corect do something, if not do something Build the %provera hash first. Once we know that hash is being built properly, we can then check for the correct user. Stop jumping ahead and concentrate on the hash for now. HTH, Charles K. Clarkson -- Mobile Homes Specialist Free Market Advocate Web Programmer 254 968-8328 If it looks wrong convert it to plain text. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>