Hallo,
ich habe mich mal mit diesem Tutorial (http://www.php-einfach.de/tuts_php_login_sessions.php) an Login-Sessions versucht.
Leider ohne erfolg.
Hier der Code:
PHP
<?php session_start(); Include("mysqlconnect.php"); ?>
<?php
//Chopper stinkt nach fisch.
$username = @$_POST['Name'];
$passwort = @$_POST['Passwort'];
$server = @$_POST['Server'];
if(!isset($_SESSION['Name'])){
$cont = "Bitte erst im <a href='./leaderpanel.php'>Leaderpanel</a> einloggen";
$sucess = 0;
}
if($server == "AL") {
$sql = 'SELECT * FROM Users_AL WHERE Name="'.$username.'" AND Leader = 1 LIMIT 1';
$serv = 1;
} else if($server == "RGN") {
$sql = 'SELECT * FROM Users_RGN WHERE Name="'.$username.'" AND Leader = 1 LIMIT 1';
$serv = 2;
} else if($server == "LOG") {
$sql = 'SELECT * FROM Users_LOG WHERE Name="'.$username.'" AND Leader = 1 LIMIT 1';
$serv = 3;
}else if($server == "") {
$cont = "Bitte wähle einen Server aus!";
$sucess = 0;
}
$result = mysql_query($sql) OR die(mysql_error());
if(mysql_num_rows($result))
{
if($serv == 1) {
$sqlPW = 'SELECT `Passwort` FROM Users_AL WHERE Name="'.$username.'" LIMIT 1';
$resultPW = mysql_query($sqlPW) OR die(mysql_error());
$rowPW = mysql_fetch_object($resultPW);
if($rowPW->Passwort == $passwort)
{
$_SESSION['Name'] = $username;
$sucess = 1;
} else {
$cont = "Das angegebene Passwort ist falsch!";
$sucess = 0;
}
} else if($serv == 2) {
$sqlPW = 'SELECT `Passwort` FROM Users_RGN WHERE Name="'.$username.'" LIMIT 1';
$resultPW = mysql_query($sqlPW) OR die(mysql_error());
$rowPW = mysql_fetch_object($resultPW);
if($rowPW->Passwort == $passwort)
{
$_SESSION['Name'] = $username;
$sucess = 1;
} else {
$cont = "Das angegebene Passwort ist falsch!";
$sucess = 0;
}
} else if($serv == 3) {
$sqlPW = 'SELECT `Passwort` FROM Users_LOG WHERE Name="'.$username.'" LIMIT 1';
$resultPW = mysql_query($sqlPW) OR die(mysql_error());
$rowPW = mysql_fetch_object($resultPW);
if($rowPW->Passwort == $passwort)
{
$_SESSION['Name'] = $username;
$sucess = 1;
} else {
$cont = "Das angegebene Passwort ist falsch!";
$sucess = 0;
}
}
}
else
{
$cont = "Dieser Account existiert nicht!";
$sucess = 0;
}
?>
Alles anzeigen
Woran liegt das, dass die Sessions nicht funktionieren?
lg