/    Sign up×
Community /Pin to ProfileBookmark

Help! Error.. Cannot send session cache limiter – headers already sent

Hey guys,

I need some quick help with an error I am getting in my login page. I am taking a php course for work and stuck on this error. The exact error is:

Warning: session_start() [function.session-start]: Cannot send session cache limiter – headers already sent (output started at /home/scott321/public_html/dl.php:1) in /home/scott321/public_html/login.php on line 12

Warning: Cannot modify header information – headers already sent by (output started at /home/scott321/public_html/dl.php:1) in /home/scott321/public_html/login.php on line 14

I did some research on this and supposidely it is because of blank spaces after my php closing statement. However I checked this everywhere and do not see any issues.. my db is set up with the table correctly. Below is a copy of the 3 php files I am using (dl.php, login.php, checklogin.php)

dl.php:

[CODE]<?php
$username=”scott321_user”;
$password=”********”;
$database=”scott321_contacts”;
$con = mysql_connect(localhost,$username,$password);
if (!$con)
{
die(‘Could not connect: ‘ . mysql_error());
}
mysql_select_db($database, $con) or die(“Couldn’t open $database: “.mysql_error());;
?>[/CODE]

login.php:

[CODE]<?php
if($_POST[‘Submit’]){
include(“dl.php”);
$userid = $_POST[‘userid’];
$password = $_POST[‘password’];
$query = “select * from users where userid=’$userid’ and password=’$password'”;
$result = mysql_query($query,$con) or die(‘Error: ‘ . mysql_error());
$num = mysql_num_rows($result);
mysql_close();
if ($num > 0 ){
session_cache_limiter(‘public’);
session_start();
$_SESSION[‘views’] = 1;
header (“Location: show_contacts.php”);
exit();
}
else {
echo “invalid userid or password try again”;
}
}?>

<!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>Untitled Document</title>
<script type=”text/javascript”>
function Validateform(){
var userid=document.form1.userid;
var password=document.form1.password;

if ((userid.value==null)||(userid.value==””)){
alert(“Please enter userid “);
userid.focus();
return false;
}

if ((password.value==null)||(password.value==””)){
alert(“Please enter password “);
password.focus();
return false;
}
return true;
}
</script>
<style type=”text/css”>
.style1 {
text-align: center;
}
</style>
</head>

<body>
<form action=”<?=$_SERVER[‘PHP_SELF’]?>” method=”post” id=”form1″ name=”form1″ onsubmit=”return Validateform();”>
<table width=”400″ border=”0″ cellspacing=”0″ cellpadding=”0″>
<tr>
<td>&nbsp;UserID</td>
<td>&nbsp;<input name=”userid” id=”userid” type=”text” ></td>
</tr>
<tr>
<td>&nbsp;Password</td>
<td>&nbsp;<input name=”password” id=”password” type=”password”></td>
</tr>
<tr>
<td colspan=”2″>&nbsp;

</td>

</tr>
<tr><td colspan=”2″ class=”style1″>
<input name=”Submit” type=”submit” value=”Log In” ></td>
</table>
</form>
</body>
</html>
[/CODE]

checklogin.php:

[CODE]<?
session_start();
if ($_SESSION[‘views’] != 1) {
header (“Location: login.php”);
exit();
}
?>[/CODE]

Any help is appreciated greatly!

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@Underboss22authorNov 15.2011 — showcontacts.php is the location I wish to have the page directed to after a successful login

Please let me know if any further details are needed to help diagnose this issue. Thanks again!
Copy linkTweet thisAlerts:
@Underboss22authorNov 15.2011 — is there a problem with my encoding that anyone can see?
×

Success!

Help @Underboss22 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...