1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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();
}
edit: könntest Du uns auch sagen wobei Du bei den Schleifen ein Problem hast??\n\n
<!--EDIT|renee|1106919657-->