Hi all,
I'm working on a CAPTCHA script and I keep getting this error:
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /mnt/w0302/d47/s14/b00686a8/www/v2/contact.php:1) in /mnt/w0302/d47/s14/b00686a8/www/v2/contact.php on line 2
I know this means I've probably got whitespace or I didn't start my session on the first line, but I've gone over this for several hours now and everything is where it should be, but I can't get rid of the error. I've tried every conceivable combination all to no avail. The funny thing is that aside from the error, the script itself works totally fine! I've tried eliminating the error with ob_flush but that doesn't work for me either so I'm at a total loss. Here's what I've got for code:
../contact.php
<?php
session_start();
$p = "contact";
include('includes/header.php');
?>
<body>
... HTML HERE ...
<?php
if(isset($_POST['secure'])) {
if($_POST['secure'] != $_SESSION['security_number']) {
$error = "Failed";
} else {
$error = "Passed";
}
}
?>
<form method="POST">
<input type="text" name="secure"><input type="submit" value="check"><br>
<img src="includes/captcha.php">
</form>
<?=$error?>
...MORE HTML ...
includes/captcha.php
<?php
session_start();
$operators=array('+','-');
$first_num=rand(1,5);
$second_num=rand(6,11);
shuffle($operators);
$expression=$second_num.$operators[0].$first_num;
eval("\$session_var=".$second_num.$operators[0].$first_num.";");
$_SESSION['security_number']=$session_var;
$img=imagecreate(100,50);
$text_color = imagecolorallocate($img,255,255,255);
$background_color= imagecolorallocate($img,0,0,0);
imagefill($img,0,150,$background_color);
imagettftext($img,16,rand(-10,10),rand(10,30),rand(25,35),$background_color,"../fonts/courbd.ttf",$expression);
header("Content-type:image/jpeg");
header("Content-Disposition:inline ; filename=secure.jpg");
imagejpeg($img);
?>
Thanks in advance for any help, I've literally been up all night with this and it's probably something ridiculously simple...
gen