fan då.. det blir bara vitt efter formuläret...
jag har i min tabell users följande fält
username, password, email, status
status är satt till 1 på alla..
login.html:
<form action="check.php" method="post">
<input type="text" name="username">
<input type="password" name="password">
<input type="submit" value="submit">
</form>
--------------------------------------------------------------------
check.php:
<?php
mysql_connect ("localhost", "retype_recol", "xxxx") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("retype_recol");
if (isset($_POST['submit'])){
$pass = md5($_POST['passwd']); // om du kör md5 på lösenordet
$sql = "SELECT status FROM users WHERE user='{$_POST['username']}' AND password='$password'";
$result = mysql_query($sql);
// Hittades inte användarnamn och lösenord
// skicka till formulär med felmeddelande
if (mysql_num_rows($result) == 0){
header("Location: login.php");
exit;
}
// Sätt sessionen med aktuell status
$_SESSION['sess_status'] = mysql_result($result, 0);
// Sessionen är satt, skicka vidare till nästa sida
header("Location: admin.php");
exit;
}
?>
----------------------------
admin.php:
<?php
session_start(); // Alltid överst på sidan
// Kolla om inloggad = sessionen satt
// Om ingen session är satt, tillbaka till login.php
if (!isset($_SESSION['sess_status'])){
header("Location: login.php");
exit;
}
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>retype.recordcollection.admin</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="../record.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<br><br><br>
<center>
<table cellpadding="0" cellspacing="0" boder="0" width="700">
<td>
<span class="rubrik">
<span class="option">Admin-mode!</span><br><br>
Record collection of:</span> jonas
<br><br>
<table width="100%" border="0" cellspacing="1" cellpadding="1">
<tr>
<td width="20%" class="rubrikcell""><span class="rubrik">Artist</span></td>
<td width="20%" class="rubrikcell""><span class="rubrik">Title</span></td>
<td width="10%" class="rubrikcell""><span class="rubrik">Format</span></td>
<td width="10%" class="rubrikcell""><span class="rubrik">Year</span></td>
<td width="20%" class="rubrikcell""><span class="rubrik">Label</span></td>
<td width="20%" class="rubrikcell""><span class="option">Options</span></td>
</tr>
<!-- loopar in skivor.. -->
<?php
if ($_SESSION['sess_status'] == 1) { // Innehållet som är för de med status 1
mysql_connect ("localhost", "retype_recol", "jeuquoo") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("retype_recol");
$result = mysql_query("SELECT \* FROM jonas ORDER BY artist;") or die("query failed");
while ($r = mysql_fetch_array($result)) {
$id = $r\[id\];
$artist = $r\[artist\];
$title= $r\[title\];
$format = $r\[format\];
$year = $r\[year\];
$label= $r\[label\];
$comment= $r\[comment\];
echo "\<tr\>";
echo "\<td class=\\"recordcell\\"\>$artist\</td\>";
echo "\<td class=\\"recordcell\\"\>$title\</td\>";
echo "\<td class=\\"recordcell\\"\>$format\</td\>";
echo "\<td class=\\"recordcell\\"\>$year\</td\>";
echo "\<td class=\\"recordcell\\"\>$label\</td\>";
echo "\<td class=\\"recordcell\\"\>\<span class=\\"option\\"\>\<a href='edit.php?id=$id'\>edit\</a\> - \<a href='delete.php?id=$id'\>delete\</a\>\</span\>\</td\>";
echo "\</tr\>";
}
}
?>
<!-- //loopar in skivor.. -->
</table>
<br><br>
<span class="link">
<a href="add.php">Add records</a> / <a href="../collection.php?user=jonas">Back to view-only mode</a>
</span>
</td>
</table>
</center>
</body>
</html>
___________________________________________________
sen är det ju meningen att select from jonas i admin.php ska bytas till select from $username osv osv...