Mine sessions virker ikke
Den reagere ikke ortenligt, og kan ikke logge af, kan i sige mig hvad der går galt?<?php
include('config.php');
session_start();
if (isset($_POST['submit'])){
$username = $_POST['username'];
$password = $_POST['password'];
$sql = "SELECT * FROM `users` WHERE `username` = '$username' AND `password` = '$password' LIMIT 1";
$result = $conn->query($sql);
if (!$result->num_rows == 1) {
echo "<br><p><center>E-mail og kodeord passer ikke sammen</p></center><br>";
} else {
$_SESSION['loggedin'] = 1;
echo "<br><p><center>Det lykkedes at logge ind</p></center><br>";
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<title></title>
<meta http-equiv="content-type" content="charset=iso-8859-1" />
<link rel="stylesheet" type="text/css" href="css/style.css">
</head>
<body>
<div id="topmenu">
<?php
if ($_SESSION['loggedin'] = 1) {
?>
<div id="login">
Velkommen du er nu logget ind.
<a class="opretbruger" href="logaf.php">Log af</a>
</div>
<?php
}else{
?>
<div id="login">
<form action="<?=$_SERVER['PHP_SELF']?>" method="post">
<a class="opretbruger" href="opret.php">Opret bruger</a>
<input id="username" type="text" name="username" value="E-mail" />
<input id="password" type="password" name="password" value="Kodeord" />
<input name="submit" type="submit" value=" Login " />
</form>
</div>
<?php
}
?>
logaf.php
session_unset();
$_SESSION = array();
session_destroy();