Hej alle.
Jeg har et problem.
Jeg har lånt bogen "Lav dit eget CMS med Dreamweaver 8, PHP og MySQL".
Det gik fint indtil jeg skulle lave login.php, når jeg går ind på de sider jeg har password beskyttet så står der:
"Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at E:\\hjemmesider\\jeppeserver1\\jeppessider.wep.dk\\admin\\index.php:1) in E:\\hjemmesider\\jeppeserver1\\jeppessider.wep.dk\\admin\\index.php on line 5
Warning: Cannot modify header information - headers already sent by (output started at E:\\hjemmesider\\jeppeserver1\\jeppessider.wep.dk\\admin\\index.php:1) in E:\\hjemmesider\\jeppeserver1\\jeppessider.wep.dk\\admin\\index.php on line 23".
Her er koden:
<?php require_once('../Connections/cms.php'); ?>
<?php
//initialize the session
if (!isset($_SESSION)) {
session_start();}
// ** Logout the current user. **
$logoutAction = $_SERVER['PHP_SELF']."?doLogout=true";
if ((isset($_SERVER['QUERY_STRING'])) && ($_SERVER['QUERY_STRING'] != "")){
$logoutAction .="&". htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_GET['doLogout'])) &&($_GET['doLogout']=="true")){
//to fully log out a visitor we need to clear the session varialbles
$_SESSION['MM_Username'] = NULL;
$_SESSION['MM_UserGroup'] = NULL;
$_SESSION['PrevUrl'] = NULL;
unset($_SESSION['MM_Username']);
unset($_SESSION['MM_UserGroup']);
unset($_SESSION['PrevUrl']);
$logoutGoTo = "../index.php";
if ($logoutGoTo) {
header("Location: $logoutGoTo");
exit;
}
}
?>
<?php
if (!isset($_SESSION)) {session_start();}
$MM_authorizedUsers = "";
$MM_donotCheckaccess = "true";
// *** Restrict Access To Page: Grant or deny access to this page
function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) {
// For security, start by assuming the visitor is NOT authorized.
$isValid = False;
// When a visitor has logged into this site, the Session variable MM_Username set equal to their username.
// Therefore, we know that a user is NOT logged in if that Session variable is blank.
if (!empty($UserName)) {
// Besides being logged in, you may restrict access to only certain users based on an ID established when they login.
// Parse the strings into arrays.
$arrUsers = Explode(",", $strUsers);
$arrGroups = Explode(",", $strGroups);
if (in_array($UserName, $arrUsers)) {
$isValid = true;
}
// Or, you may restrict access to only certain users based on their username.
if (in_array($UserGroup, $arrGroups)) {
$isValid = true;
}
if (($strUsers == "") && true) {
$isValid = true;
}
}
return $isValid;
}
$MM_restrictGoTo = "../index.php";
if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {
$MM_qsChar = "?";
$MM_referrer = $_SERVER['PHP_SELF'];
if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&";
if (isset($QUERY_STRING) && strlen($QUERY_STRING) > 0)
$MM_referrer .= "?" . $QUERY_STRING;
$MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer);
header("Location: ". $MM_restrictGoTo);
exit;
}
?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
$colname_rsSideindhold = "-1";
if (isset($_GET['id'])) {
$colname_rsSideindhold = $_GET['id'];
}
mysql_select_db($database_cms, $cms);
$query_rsSideindhold = sprintf("SELECT * FROM sideindhold WHERE id = %s ORDER BY id DESC", GetSQLValueString($colname_rsSideindhold, "int"));
$rsSideindhold = mysql_query($query_rsSideindhold, $cms) or die(mysql_error());
$row_rsSideindhold = mysql_fetch_assoc($rsSideindhold);
$totalRows_rsSideindhold = mysql_num_rows($rsSideindhold);
?><!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Forside</title>
<style type="text/css">
<!--
.style1 {font-family: Verdana, Arial, Helvetica, sans-serif}
.style2 {color: #3300FF}
.topbordercells {
border-top-width: 1px;
border-top-style: dotted;
border-top-color: #000000;
vertical-align: top;
}
#rssico {
position: absolute;
right: 0%;
bottom: 0%;
}
#news {
}
-->
</style>
<link href="../css/style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<table width="100%" border="0" cellpadding="0" cellspacing="0" class="layout">
<tr>
<td height="50" colspan="2" class="top"><h1 align="center">Jeppessider</h1></td>
</tr>
<tr>
<td class="menu">
<p><img src="../billeder/titleimg_menu.jpg" width="150" height="21" /></p>
<p><span class="style2"><a href="../index.php">Forside</a></span></p>
<p class="style2"><a href="hundebilleder.html">Hundealbummet</a></p>
<p class="style2"><a href="../index.php?id=2">Downloads</a></p>
<p class="style2"><a href="../index.php?id=3">Links</a></p>
<p><span class="style2"><a href="kontakt.php">Kontakt mig</a></span></p></td>
<td class="right"><table border="0" align="right" cellpadding="0" cellspacing="0">
<tr>
<td width="50"><a href="<?php echo $logoutAction ?>">Log ud</a></td>
</tr>
</table>
<p> </p>
<table width="80%" border="0" cellpadding="0" cellspacing="0" class="indhold">
<tr>
<td height="21"><a href="../index.php?id=1">Forside</a>-<a href="admin_edit_indhold.php?id=1">Rediger</a></td>
</tr>
<tr>
<td height="30"><a href="../index.php?id=3">Link-side</a>-<a href="admin_edit_indhold.php?id=3">Rediger</a></td>
</tr>
<tr>
<td class="indhold"><a href="../index.php?id=2">Downloads</a>-<a href="admin_edit_indhold.php?id=2">Rediger</a></td>
</tr>
<tr>
<td class="topbordercells"><div align="left"></div></td>
</tr>
<tr>
<td class="topbordercells"><p> </p> </td>
</tr>
</table> </td>
</tr>
</table>
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
var pageTracker = _gat._getTracker("UA-3961990-2");
pageTracker._initData();
pageTracker._trackPageview();
</script>
</body>
</html>
<?php
mysql_free_result($rsSideindhold);
?>
På forhånd tak
Venlig hilsen Jeppe.
Indlæg senest redigeret d. 14.05.2008 15:28 af Bruger #13488