Hallo,
ich habe mir ein einfaches sessionbasiertes Login System geschrieben.
Problem: Die Dateien werden nicht includet.
index.php
<?php
session_start();
// LOGGED IN?
if ($_SESSION['logged_in'] != true) {
header("Location: login.php"
}
else {
include("../config.php"
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>GAG's Admin</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="../css/style.css">
<script language="JavaScript1.2" src="../js/functions.js" type="text/javascript"></script>
</head>
<div id="admin_aussen">
<div id="admin_innen">
<?
$_GET['action'] = "home";
if (!file_exists("" . $_GET['action'] . ".php")
echo "Die Seite existiert nicht.";
else
include ("" . $_GET['action'] . ".php"
?>
</div>
<a href="index.php?action=home">Admincenter</a><br> <a href="logout.php">Logout</a>
</div>
</body>
</html>
<? } ?>
login.php
<?php
if (isset($_POST['submit'])) {
session_start();
// user-129utzername und Passwort werden überprüft
include("../config.php"
$abfrage = "SELECT * FROM `gag_user` WHERE id = ".$_POST['username']."";
$sql = mysql_query($abfrage) OR die(mysql_error());
$user = mysql_fetch_assoc($sql);
if ($_POST['passwort'] == $user['passwort']) {
$_SESSION['logged_in'] = true;
// Weiterleitung zur geschützten Startseite
header("Location: index.php"
}
else {
header("Location: login.php"
}
}
include("../config.php"
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="de" lang="de">
<head>
<title>Geschützter Bereich</title>
<link rel="stylesheet" type="text/css" href="../css/style.css">
</head>
<body>
<br/><br/>
<form action="login.php" method="post">
<table width="400" border="0" cellpadding="1" cellspacing="1" bgcolor="#000000" align="center">
<tr bgcolor="#FA7405">
<td colspan="2"><b>Login</b></td>
</tr>
<tr>
<td width="150" bgcolor="#eeeeee">Name:</td>
<td width="250" bgcolor="#ada5a5">
<select name="username" class="input">
<?php
$abfrage = "SELECT * FROM `gag_user`";
$sql = mysql_query($abfrage);
while($zeile = mysql_fetch_array($sql)) {
echo '<option value="'.$zeile["id"].'">'.$zeile["name"].'</option>';
}
?>
</select>
</td>
</tr>
<tr>
<td bgcolor="#eeeeee">Passwort:</td>
<td bgcolor="#ada5a5"><input name="passwort" type="password" class="input"></td>
</tr>
<tr>
<td colspan="2" bgcolor="#FA7405"><input type="submit" value="Anmelden" name="submit" class="input"/></td>
</tr>
</table>
</form>
</body>
</html>
Der Login funktioniert ohne Probleme. Nur ich kann keine Dateien includen.
<a href="index.php?action=datei">Datei</a> -> so include ich
Das steht in jeder Datei:
session_start();
// LOGGED IN?
if ($_SESSION['logged_in'] != true) {
header("Location: login.php"
}
else {
echo "muh"
} ?>
Ich kann mir leider nicht mehr weiterhelfen... Suche schon seit Stunden die Lösung. Ist mein erstes System dieser Art.
Dankeschön!