Problem med sessions
Hvorfor sendes ikke videre til test2.php, men bliver på test.php, ingen fejlmeddelelse:<?php
ob_start();
session_start();
?>
<?php
if (isset($_POST['submitted'])) {
require_once('Connect.php');
if (!empty($_POST['email'])) {
$e = $_POST['email'];
} else {
echo '<p>Du glemte at indtaste e-mailadresse.</p>';
$e = FALSE;
}
if (!empty($_POST['kode'])) {
$k = $_POST['kode'];
} else {
$k = FALSE;
echo '<p>Du glemte at indtaste kodeord.</p>';
}
if ($e && $k) {
$query = "SELECT Bruger_id, Fornavn FROM brugere WHERE (Email='$e' AND Kode=SHA('$k')) AND Aktiveringskode IS NULL";
$result = mysql_query ($query) or trigger_error("Query: $query\n<br />MySQL Error: " . mysql_error());
if (@mysql_num_rows($result) == 1) {
$row = mysql_fetch_array ($result, MYSQL_NUM);
mysql_free_result($result);
mysql_close();
$_SESSION['Fornavn'] = $row[1];
$_SESSION['Bruger_id'] = $row[0];
$url = 'http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']);
if ((substr($url, -1) == '/') OR (substr($url, -1) == '\\') ) {
$url = substr ($url, 0, -1);
}
$url .= '/test2.php';
ob_end_clean();
header("Location: $url");
exit();
} else {
echo '<p>Fejl i indtastning.</p>';
}
} else {
echo '<p>Prøv venligst igen.</p>';
}
mysql_close();
}
?>
<h1>Login</h1>
<div><form action="test.php" method="post">
<fieldset>
<p><b>Email:</b> <input type="text" name="email" id="email" size="20" maxlength="40" value="<?php if (isset($_POST['email'])) echo $_POST['email']; ?>" /></p>
<p><b>Kodeord:</b> <input type="password" name="kode" id="kode" size="20" maxlength="20" /></p>
<input type="submit" name="submit" value=" Login " />
<input type="hidden" name="submitted" value="TRUE" />
</fieldset>
</form></div>
<?php
if (isset($_SESSION['Bruger_id']) AND (substr($_SERVER['PHP_SELF'], -10) != 'logout.php')) {
echo '<a href="logout.php">Logout</a><br />
<a href="change_password.php">Change Password</a><br />
';
} else {
echo ' <a href="register.php">Register</a><br />
<a href="login.php">Login</a><br />
<a href="forgot_password.php">Forgot Password</a><br />
';
}
?>
<?php
ob_flush();
?>