9 Einträge, 1 Seite |
1
2
3
4
5
6
7
8
9
10
11
12
13
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 = qq{insert into mitglieder (password,nick) values (?,?)};
my $sth = $dbh->prepare($sql);
my @i <= $#fields && defined({$fields[0]}
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();
}
1
2
3
4
5
6
7
8
DROP TABLE IF EXISTS `mitglieder`;
CREATE TABLE `mitglieder` (
`id` int(11) NOT NULL auto_increment,
`password` longtext,
`username` longtext,
`nick` longtext,
PRIMARY KEY (`id`)
) TYPE=ISAM PACK_KEYS=1;
1
2
3
my $sql_insert = qq{insert into mitglieder (password,nick) values (?,?)};
my $sql_select = qq~SELECT * FROM mitglieder WHERE password = ? AND nick = ?~;
my $sql_update = qq~UPDATE mitglieder SET password = ? WHERE nick = ?~;
1
2
3
4
5
6
7
8
9
10
11
12
13
for (my $i=0;$i<20;$i++)
{
if ($i <= $#fields && defined($user->{$fields[$i]}))
{
my $field = $fields[$i] eq $user->{$fields[$i]};
$field =~ s/[\r\n]//g;
print FILE "$field\n";
}
else
{
print FILE "\n";
}
}
9 Einträge, 1 Seite |