Login og Sessions
Hej!Jeg har ikke helt fattet sessions ... Hvad gør jeg galt her?:
--- index.php:
<?php
if (isset($_SESSION['admin'])) {
Print "INDE";
} else {
print "<H1>LOGIN</h1>";
print "
<FORM method=\"post\" action=\"do_login.php\">
U: <INPUT type=\"text\" name=\"f_username\"><BR>
P: <INPUT type=\"password\" name=\"f_password\"><BR>
<INPUT type=\"submit\" value=\"OK\">
</FORM>
";
}
?>
--- do_login.php
<?
include("conn_MySQL.inc");
if (isset($_REQUEST['f_username'])) $f_username = $_REQUEST['f_username'];
if (isset($_REQUEST['f_password'])) $f_password = $_REQUEST['f_password'];
if($f_username && $f_password){
$rs = mysql_query("SELECT * FROM admin WHERE user = '$f_username' AND password = '$f_password'");
$antal = mysql_num_rows($rs);
if($antal > 0){
session_register("admin_name", "admin_email", "admin");
$admin = 1;
$row = mysql_fetch_array($rs);
$admin_name = $row["Name"];
$admin_email = $row["Email"];
header("location: index.php");
} else {
header("location: index.php?login_error_code=1");
}
} else {
header("location: index.php?login_error_code=2");
}
mysql_close($db);
?>
