Thread Ganz simples User management? (37 answers)
Opened by FlorianL at 2007-07-20 11:06

FlorianL
 2007-07-20 12:55
#78690 #78690
User since
2007-05-18
142 Artikel
BenutzerIn
[default_avatar]
@RPerl:

du hast mich überzeugt, ich werd Simple::Login weglassen, aber kannst du mir ne kleine hilfestellung geben? ist mein erster versuch mit DBI, und sql statements muss ich auch jedes mal nachschlagen :/

Script mit Pseudo-Code
Code (perl): (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/usr/bin/perl
use warnings;
use strict;
use DBI;

my $gamebin = "/usr/games/slashem";

### DB ###
my $database = "nethack";
my $hostname = "127.0.0.1";
my $dsn      = "DBI:mysql:database=$database;host=$hostname";
my $dbuser   = "nethack";
my $dbpasswd = 'whatApa55';
my $dbh = DBI->connect( $dsn, $dbuser, $dbpasswd, {RaiseError => 1, AutoCommit => 0} ) || die $DBI::errstr;

### SUBS ###
sub countusers {
        my $sth = $dbh->prepare( q{ SELECT username from users });
        my $rc = $sth->execute;
        print "$sth->{NUM_OF_FIELDS}";
        $dbh->disconnect;
}
sub auth {
        my ($login, $password) = shift;
        # Hier brauch ich hilfe
}

sub game {
        system("clear");
        print("Hello welcome to SlashEm!\n\nSlashEm is a modification of the great NetHack Game...\nMore Info: http://nethack.org/v343/Guidebook.html or press '?' ingame...");
        sleep("5");
        print("Login: ");
        chomp(my $login = <STDIN>);
        print("\nPassword: ");
        chomp(my $password = <STDIN>);
        auth($login, $password);
# wenn login = nicht vorhanden, neu erstellen: createuser();
# wenn login vorhanden, passwort abgleichen;
# wenn pass falsch -> exit;
# wenn pass richtig -> login fertig;
        system("clear");
        print("You enter the World of SlashEm... Currently there are", countusers(), "Users registered\n\n");
        sleep("2");
}


### MAIN ###
#system("$gamebin -u $name");

View full thread Ganz simples User management?