Thread Benutzername u. Passwortabfrage mit Perl/CGI (9 answers)
Opened by maxtorman at 2010-02-14 00:08

Gast maxtorman
 2010-02-15 17:43
#133014 #133014
wie mache ich den abgleich mit den eingegebenen daten aus html-formular?
leider klappt dies noch nicht ganz. wird aber nicht mehr viel fehlen. wo ist der fehler?

dies ist die html:

Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
<html>
<head>
<title>Abfrage Benutzername und Passwort</title>
</head>
<body>
<form action="/cgi-bin/passwort.cgi" method=POST>
Benuzername: <input type="text" name="name" size="15"><br>
Passwort: <input type="text" name="passwort" size="15" /><br>
<input type="submit" value="Login">
<input type="RESET" value="Löschen">
</form>
<br><br>
</body>
</html>


und dies ist die passwort.cgi:

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
#!c:/programme/perl/bin/perl.exe -w
read(STDIN, $Daten, $ENV{'CONTENT_LENGTH'});
print "Content-type: text/html\n\n";
print "<html>";
print "<head>";
print "<title> Berechnung des CGI-Programms </title>";
print "</head>\n";
print "<body>";
print "<div align=center><h1>Antwortseite des CGI-Programms</h1>";
print "<hr>";
print "<b>$Daten</b>";
print "</div>";
$login = 0;
open (LESEN, "<passwort.txt") || die "Die Datei $! kann nicht geoeffnet werden";
while ($zeile = <LESEN>)
{
chomp($zeile);
($username, $userpasswort) = split(/,/, $zeile);
if ($name eq $username && $passwort eq $userpasswort)
{
$login = 1;
last;
}
}
close LESEN;
if ($login)
{ 
print "Sie werden eingeloggt!";
}
else
{
print "Die eingegebenen Daten sind nicht korrekt. Sie werden nicht eingeloggt!";
print "$name";
}
print "</body>";
print "</html>";


mod-edit pq: code-tags hinzugefĆ¼gt
Last edited: 2010-02-15 17:46:39 +0100 (CET)

View full thread Benutzername u. Passwortabfrage mit Perl/CGI