Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Loginabfrage erstellen in eine Homepage

Empfohlene Antworten

Veröffentlicht

Hallo, wer kann mir helfen beim erstellen einer Loginabfrage (Benutzername und Passwort)oder wer hat sogar schnell mal einen da. Und wie halte ich die Daten fest inder Datenbank ? Danke

Verschoben --> ASP/PHP

Hoi..

ich post hier mal eine Lösung in Perl mit Datenabfrage aus einer MySQL Datenbank und nach erfolgreichem Login setzen von einem Cookie.


#!/usr/bin/perl


use DBI;

use CGI qw/:all/;


my $cmd		= param('cmd');

my $user        = param('user');

my $passwort    = param('passwort');


my $DATABASE = "dbi_mysql:webdb";

my $USERNAME = "user";

my $PASSWORD = "passwort";


if ($cmd eq "login") {	# Nachpruefen ob alle Angaben vorhanden sind

	if (!$user)	{ &send_login_page("Bitte geben Sie Ihren Benutzernamen ein."); }

	elsif (!$passwort) { &send_login_page("Bitte geben Sie Ihr Passwort ein."); }

	else	{ &identify_user($user, $passwort); }

}

else { &send_login_page; } # Beim ersten Aufruf LoginSeite ausgeben


#################################################

# Login Seite                               S U B

#################################################


sub send_login_page {


my $message = shift;


print "Content-type: text/html\n\n";

print <<eof;

<html>

<head>

<title>Login</title>

</head>

<body>

<br>

<div align="center">$message</div>

<br>

<form name="login" action="$ENV{SCRIPT_NAME}" method="post">

<input type="hidden" name="cmd" value="login">

<table border="0" align="center">

	<tr>

	   <td>User:</td>

	   <td><input type="text" name="user" size=25 select></td>

	</tr>

	<tr>

	   <td>Passwort:</td>

	   <td><input type="password" name="passwort" size=25></td>

	</tr>

	<tr>

		<td align="center" colspan="2"><input type="submit" value="Einloggen"></td>

	</tr>

</table>	  

</form>

</body>

</html>

eof

}


#################################################

# Vorgang fehlgeschlagen                    S U B

#################################################


sub send_login_failed {


        my $reason = shift;

        my $user = shift;


print "Content-type: text/html\n\n";

print <<eof;

<html>

<head>

<title>Login gescheitert</title>

</head>


<body>

<br>

<div align="center">Login gescheitert</div>

<br><br><br>

<div align="center">$reason

<br><br>

Bitte kehren Sie mit dem "Zurück"-Button auf die vorhergehende Seite<br>

zurück und versuchen Sie es noch einmal.

</div>


</body>

</html>

eof

}  


#################################################

# User identifizieren                       S U B

#################################################


sub identify_user {


    my $user        = shift;

    my $passwort    = shift;


    $dbh = DBI->connect($DATABASE, $USERNAME, $PASSWORD);

	$statement = "SELECT user, password FROM accounts WHERE user = '$user'";

    $sth = $dbh->prepare($statement);

    $sth->execute;

    (my $identy_user, my $identy_passwort) = $sth->fetchrow_array();

    $sth->finish;

    $dbh->disconnect;


	if ($user eq $identy_user && $passwort eq $identy_passwort) {


	    my $encrypted = crypt ("$passwort", "xy");

	    print "Set-Cookie: LOGINBEREICH=$user-$encrypted; path=/; domain=$ENV{'SERVER_NAME'} \n";

        print "Content-type: text/html\n\n";


print <<eof;

        <html>

        <body>

	    <script language=javascript>

	        parent.location.href = "weiter.pl"

        </script>

	    </body>

	    </html>

eof

        }

	    else {

	        my $fail_message = "Benutzername / Passwort stimmen nicht überein.";

	    	&send_login_failed($fail_message, $user);

        	exit;

        }	

} 

Kann sein, dass es den Quelltext ein bissl zerrissen hat,.. in einem textarea Feld kann man so schlecht die Formatierung wiederherstellen ;)

<FONT COLOR="#a62a2a" SIZE="1">[ 12. Dezember 2001 12:11: Beitrag 2 mal editiert, zuletzt von BigMac ]</font>

reicht dir keine .htaccess ???

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.