Problem bei Login

peti03100

Grünschnabel
Hallo.

Ich habe ein Problem bei meinem Loginsystem. Es gibt mehrere Profile und jeder Account hat seine Infos. Und soblad man sich mit Benutzername und Passwort angemeldet hat sollen diese erscheinen. Das ganze befindet sich in 2 Datein:

1. login2.php
PHP:
<?php
	session_start();
	$spieler = $_Session['name'];
	$spielerid = $_Session['id'];
?>

<html xmlns="http://www.w3.org/1999/xhtml">

<head>
    <title>Alenan</title>

    <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1" />
    <meta name="description" content="Alenan" />
    <meta name="author" content="Peter Amleang und Maximilian Koch" />
    <meta name="keywords" content="alenan fern&ouml;stlich" />

    <link rel="shortcut icon" href="http://www.tutorials.de/images/fav.ico">
    <link href="../styles/style.css" type="text/css" rel="stylesheet" />
</head>

<body>

<br />

<center>
<div class="right">
<div class="righto">
<p>&nbsp; Anmelden :</p>
<?php


	if ($_POST['loginbtn']){
		$spieler = strip_tags($_POST['name']);
		$passwort = strip_tags($_POST['passwort']);

		if ($spieler && $passwort){

			include("../include/connect.php");
			$pass = $passwort;

			$query = mysql_query("SELECT * FROM spieler WHERE name='$spieler' AND passwort='$pass'");
			$numrows = mysql_num_rows($query);

			if ($numrows == 1){

				$row = mysql_fetch_assoc($query);
				$dbid = $row['id'];
				$dbuser = $row['name'];
				$active = $row['aktiv'];
				$loggedin = $row['loggedin'];

				if ($active == 1){

					$date = date("d.m.Y, H:i");

					mysql_query("UPDATE spieler SET last_login='$date' WHERE id='$dbid'");

					$_SESSION['name'] = $dbuser;
					$_SESSION['spielerid'] = $dbid;

					echo "<body onLoad=\"setTimeout('redirect();', 3000);\">";
					echo "Du hast dich erfolgreich angemeldet, <b>".$_SESSION['name']."</b>. <br><a href='../usr/profile.php'>Falls die automatische Weiterleitung nicht funktioniert, klicken bitte hier!</a></body>";
				}
				else
					echo "Dein Account ist leider noch nicht aktiv.";
			}
			else
				echo "Falsche Logindaten.

				<form action='../log/login2.php' method='post'>
<table border='0' width='240'>
<tr>
<td>Benutzername:</td><td><input type='text' name='name' class='textbox'></td>
</tr>
<tr>
<td>Passwort:</td><td><input type='password' name='passwort' class='textbox'></td>
</tr>
</table>
<center><input type='submit' name='loginbtn' value='Login' class='button'></center>
				";
                exit;
		}
		else
			echo "Sie haben nicht alle nötigen Felder ausgefüllt.

				<form action='../log/login2.php' method='post'>
<table border='0' width='240'>
<tr>
<td>Benutzername:</td><td><input type='text' name='name' class='textbox'></td>
</tr>
<tr>
<td>Passwort:</td><td><input type='password' name='passwort' class='textbox'></td>
</tr>
</table>
<center><input type='submit' name='loginbtn' value='Login' class='button'></center>
				";
	}
	else

	     echo "<form action='../log/login2.php' method='post'>
<table border='0' width='240'>
<tr>
<td>Benutzername:</td><td><input type='text' name='name' class='textbox'></td>
</tr>
<tr>
<td>Passwort:</td><td><input type='password' name='passwort' class='textbox'></td>
</tr>
</table>
<center><input type='submit' name='loginbtn' value='Login' class='button'></center>
				";
	?>
</div>
</div>
</center>
</body>
</html>

und
2. profile.php
PHP:
<?php include("../include/connect.php");

	session_start();
	$spieler = $_Session['name'];
	$spielerid = $_Session['id'];
?>
<html>

<head>
    <title>Alenan</title>
    <link rel="shortcut icon" href="http://www.tutorials.de/images/fav.ico" />
    <link href="../styles/style.css" type="text/css" rel="stylesheet" />
</head>
<?php

  $spielerinfo = "Select * from spieler where name='$spieler'";
  $spielerinfo2 = mysql_query($spielerinfo) or die ("Fehler!");
  $spielerinfo3 = mysql_fetch_array($spielerinfo2);

 ?>
<body>

<br />

<center>
<div class="right">
<div class="righto">

<?php

    if($spieler)
    {

    $level = $spielerinfo3['level'];
    $lp = $spielerinfo3['lp'];
    $mp = $spielerinfo3['mp'];
    $exp = $spielerinfo3['exp'];

    echo "Account: ";
    echo $spieler;

    echo "<br /><br />Level: ". $level;
    echo "<br />Leben: ". $lp;
    echo "<br />Mana: ". $mp;
    echo "<br />Exp: ". $exp;
    }
    else
    {
    echo "Sie sind nicht angemeldet!";
    }
?>
</div>
</div>

</center>

</body>
</html>

Immer wenn ich bei Erfolgreichem Login auf die weiterleitung klicke werde ich zwar auf die profile.php weitergeleitet, aber es wird ausgegeben das ich nicht angemeldet bin.

mfg peti03100
 
Zuletzt bearbeitet:
Also ich habe das jetzt noch ganz oben an die profile.php Datei angehängt.
PHP:
<?php include("../include/connect.php");

	session_start();
	$spieler = $_Session['name'];
	$spielerid = $_Session['id'];
?>
 
Ich habe jetzt überall es in das hier geändert
PHP:
<?php
	session_start();
	$spieler = $_Session['name'];
	$spielerid = $_Session['id'];
?>
<?php include("../include/connect.php");?>

Ist das Richtig? Weil es klappt immer noch nicht.
 
Zurück