use DBI; my($main,$password,$nick); my $db_name = "DBI:mysql:users"; ## den Datenbankname ersetzen my $db_user = "root"; ## Benutzername my $db_pass = ""; ## Passwort my @ergebnis; my $test; my $dbh = DBI->connect("$db_name","$db_user","$db_pass") || die "Database connection not made: $DBI::errstr"; my $sql_insert = qq{insert into mitglieder (password,nick) values (?,?)}; my $sql_select = qq~SELECT * FROM user WHERE password = ? AND nick = ?~; my $sql_update = qq~UPDATE user SET password = ? WHERE nick = ?~; my $sth = $dbh->prepare($sql_select) or die $dbh->errstr(); $sth->execute($password,$nick) or die $dbh->errstr(); if($sth->fetchrow_array()){ $sth = $dbh->prepare($sql_update) or die $dbh->errstr(); $sth->execute($password,$nick); } else{ $sth = $dbh->prepare($sql_insert) or die $dbh->errstr(); $sth->execute($password,$nick) or die $dbh->errstr(); }