Session Problem
Posted: Sat Sep 02, 2006 2:41 pm
I am trying to create templates for my site; so, it doesnt have to keep using hardcoded html/php.
My news.php and index.php are setup like so: (meaning the use of includes)
Notice the include 'templates/forms/logon.php'; on about the 5th line. This loads a form which I am trying to use to allow the user to logon.
Here is the code for templates/forms/logon.php
I'm now getting this error when viewing the news.php
Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /home/content/t/i/m/timothytmaiden/html/templates/header.php:46) in /home/content/t/i/m/timothytmaiden/html/templates/forms/logon.php on line 24
Any clue to how I can resolve this?
My news.php and index.php are setup like so: (meaning the use of includes)
Code: Select all
<?php
include('config.php');
include 'templates/header.php';
include 'templates/navigation/toptabs.php';
?>
<div id="container">
<?
include 'templates/forms/logon.php';
include 'templates/logo.php';
include 'templates/navigation/navitabs.php';
include 'templates/description.php';
?>
<div id="main">
</p>
<h3>Thursday, August 31th 2006:</h3>
<p>
More HTML -> PHP migration.
</p>
<br>
<?
include 'templates/pagead.php';
?>
</div>
<?
include 'templates/sidebar.php';
include 'templates/footer.php';
?>Here is the code for templates/forms/logon.php
Code: Select all
<?php
include('config.php');
if(isset($_POST['username'])){
//Connect to database
mysql_connect ( $dbhost, $dbuser, $dbpass)or die("Could not connect: ".mysql_error());
mysql_select_db($dbname) or die(mysql_error());
$username = $_POST['username'];
$password = md5($_POST['password']);
$query = "SELECT * FROM ff_users WHERE username = '" . $username . "' and password = '" . $password . "'";
$result = mysql_query($query);
if (! mysql_num_rows($result)){
echo "<form name=\"login\" method=\"post\" action=\"" . substr($_SERVER['REQUEST_URI'], 1) . "\">
<div id=\"sideform\">
<input type=\"text\" name=\"username\" size=\"15\" class=\"\" maxLength=\"20\">
<input type=\"password\" name=\"password\" size=\"15\" class=\"\" maxLength=\"20\">
<input type=\"submit\" name=\"submit\" value=\"Logon\">
</div>
</form><br><b>Invalid Username or Password</b>";
}
else{
session_start();
$_SESSION['username'] = $username;
}
}
if(isset($_SESSION['username'])){
echo "<div id=\"sideform\">Welcome, <b>" . $_SESSION['username'] . "</b></div></form>";
}
else{
echo "<form name=\"login\" method=\"post\" action=\"" . substr($_SERVER['REQUEST_URI'], 1) . "\">
<div id=\"sideform\">
<input type=\"text\" name=\"username\" size=\"15\" class=\"\" maxLength=\"20\">
<input type=\"password\" name=\"password\" size=\"15\" class=\"\" maxLength=\"20\">
<input type=\"submit\" name=\"submit\" value=\"Logon\">
</div>
</form>";
}
?>Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /home/content/t/i/m/timothytmaiden/html/templates/header.php:46) in /home/content/t/i/m/timothytmaiden/html/templates/forms/logon.php on line 24
Any clue to how I can resolve this?