Jump to content

Help Please


unidox

Recommended Posts

I am making a new cms where it is built into the site.

 

But I keep getting this error:

 

Warning: Cannot modify header information - headers already sent by (output started at *****:16) in *****inc/func.inc.php on line 10

 

Here is my index.php:

 

<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>New Page 1</title>
</head>

<body>
<!--
This is where the main body will go
-->
Testing
<!--
This starts the admin panel
-->
<?php
/*
Login Panel
*/
if ($_REQUEST['adm'] == "login") {
	$page = "Login";
	require_once ("inc/db.inc.php");
	require_once ("inc/func.inc.php");
	if ($_REQUEST['m']) {
		if ($_REQUEST['m'] == "1") {
			$loginpass = 		$_POST['login_pass'];
			$password = 		md5($loginpass);
			$loginname = 		$_POST['login_name'];
			$checkrows = 		mysql_query ("SELECT * FROM admin_users WHERE username='$loginname' && password='$password'") or die (mysql_error());
			$rowcount = 		mysql_num_rows ($checkrows);
			if ($rowcount == "0") {
					showError("User/Login Error");
					exit;
			}
		if ($rowcount != "0") {
			header ("Location: index.php?adm=home");
			$time = 		date("h:i:a");
			$date = 		date("m/d/Y");
			$last_logged = 	$time . "\n(" . $date . ")";
			$ip = 			getenv ("REMOTE_ADDR");
			MYSQL_QUERY("UPDATE admin_users SET last_logged='$last_logged', cur_ip='$ip' WHERE username='$loginname'") or die (mysql_error());
			while ($mysql=mysql_fetch_array($checkrows)) {
				setcookie("access", $mysql[access],time()+60*60*24*30);
			}
			setcookie ("uniqueid",$loginname,time()+60*60*24*30);
			exit;
		} 
	}		
		elseif ($_REQUEST['m'] == "2") {
			header ("Location: index.php?adm=login");
			setcookie ("uniqueid");
			setcookie ("access");
			exit;
		}
	}
		else {
			if ($_COOKIE['uniqueid'] == "") {
				$checkfields = "login_name&login_pass";
				$errors = "Enter a username&Enter a password!";
				$titles = "Username:&Password:";
				$fields = "login_name&login_pass";
				$type = "text&password";
				$size = "30&30";
				$maxlength = "25&25";
				getHeader();
				createJSValid($checkfields,$errors);
				createForm($titles,$fields,$type,$size,$maxlength,'1','','','','1');
		}
		else {
			showError("You are already logged in, <a href=\"" . $_SERVER['PHP_SELF'] . "?m=2\">logout?</a>");
	}
}
}
?>
</body>

</html>

 

Here is part of my inc/func.inc.php(lines 0 -50):

 

<?php
require_once 'config.inc.php';
$oncolour = "#BCD5FE";
$offcolour = "#FFFFFF";
$bdrcolour = "#F0F0F0";

$islogged = preg_match("/index.php?adm=login/", $_SERVER['PHP_SELF']);
if ($islogged == "0") {
	if ($_COOKIE['uniqueid'] == "") {
		header ("Location: index.php?adm=home");
		exit;
	}
}

if ((!$_REQUEST['method']) || (!$_COOKIE['uniqueid'])) {
	$access = $_COOKIE['access'];
	if (array_search($page,$levels)) {
		if ($access <= $levels[$page]) { // less than or equal to as the higher you go the less privileges you have
			echo $access . $levels[$page];
			//showError('You do not have access to this page.');
			exit;
		}
	}
}

$browser = 'An Unidentified Browser';


$viewer = getenv('HTTP_USER_AGENT');


if (preg_match( "/MSIE/i", "$viewer" ) )

	{ $browser = 'Internet Explorer'; }

if (preg_match( "/Netscape/i", "$viewer" ) )

	{ $browser = 'Netscape'; }

if (preg_match( "/Opera/i", "$viewer" ) )

	{ $browser = 'Opera'; }

if (preg_match( "/Firefox/i", "$viewer" ) )

	{ $browser = 'Mozilla Firefox'; }



 

Please help.

Link to comment
Share on other sites

No...you have all this output at the start of your index page.

 

<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>New Page 1</title>
</head>

<body>
<!--
This is where the main body will go
-->
Testing
<!--
This starts the admin panel
-->

Link to comment
Share on other sites

Change your index.php code to this:

 

<?php ob_start(); ?>

<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>New Page 1</title>
</head>

<body>
<!--
This is where the main body will go
-->
<!--
This starts the admin panel
-->
<?php
/*
Login Panel
*/
if ($_REQUEST['adm'] == "login") {
	$page = "Login";
	require_once ("inc/db.inc.php");
	require_once ("inc/func.inc.php");
	if ($_REQUEST['m']) {
		if ($_REQUEST['m'] == "1") {
			$loginpass = 		$_POST['login_pass'];
			$password = 		md5($loginpass);
			$loginname = 		$_POST['login_name'];
			$checkrows = 		mysql_query ("SELECT * FROM admin_users WHERE username='$loginname' && password='$password'") or die (mysql_error());
			$rowcount = 		mysql_num_rows ($checkrows);
			if ($rowcount == "0") {
					showError("User/Login Error");
					exit;
			}
		if ($rowcount != "0") {
			header ("Location: index.php?adm=home");
			$time = 		date("h:i:a");
			$date = 		date("m/d/Y");
			$last_logged = 	$time . "\n(" . $date . ")";
			$ip = 			getenv ("REMOTE_ADDR");
			MYSQL_QUERY("UPDATE admin_users SET last_logged='$last_logged', cur_ip='$ip' WHERE username='$loginname'") or die (mysql_error());
			while ($mysql=mysql_fetch_array($checkrows)) {
				setcookie("access", $mysql[access],time()+60*60*24*30);
			}
			setcookie ("uniqueid",$loginname,time()+60*60*24*30);
			exit;
		} 
	}		
		elseif ($_REQUEST['m'] == "2") {
			header ("Location: index.php?adm=login");
			setcookie ("uniqueid");
			setcookie ("access");
			exit;
		}
	}
		else {
			if ($_COOKIE['uniqueid'] == "") {
				$checkfields = "login_name&login_pass";
				$errors = "Enter a username&Enter a password!";
				$titles = "Username:&Password:";
				$fields = "login_name&login_pass";
				$type = "text&password";
				$size = "30&30";
				$maxlength = "25&25";
				getHeader();
				createJSValid($checkfields,$errors);
				createForm($titles,$fields,$type,$size,$maxlength,'1','','','','1');
		}
		else {
			showError("You are already logged in, <a href=\"" . $_SERVER['PHP_SELF'] . "?m=2\">logout?</a>");
	}
}
}
?>
</body>
</html>

<?php ob_end_flush(); ?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.