Jump to content

headers already sent


r-it

Recommended Posts

I was wondering if someone can plese help me with this: I have a page called print.php which is a redirect from the vacancies page, all i want to do is to print a vacancy on a white-background page, and thus my redirecting the page to this one. the problem is that once it is on that page, it does not redirect back to the previous page when it's done printing, and i think i'm not completely grasping the whole ob_start and ob_end_flush concepts, but i have used them before and they worked fine, please tell me what i am doing wrong, here is the code:

<?php
session_start();
include_once "connex.php";
$conn = new dbConnector();
ob_start();
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta content="Recruitment, Better Your Odds, BYO, BEE, B.E.E, B.Y.O" name="keywords">
<title>Better Your Odds</title>
    
</head>
<body onLoad="window.print()">
<?php 
	/*
	$delim = '^';
	$word = strtok($text, $delim);
	$d_block .= "<ul>";
	while(is_string($word))
	{
		if($word)
		{
			$d_block .= "<li>$word<br></li><br>";
		}
		$word = strtok($delim);
	}
	*/

$vacss = $_SESSION['vacs'];

$delim = ',';
$v = strtok($vacss, $delim);
while(is_string($v))
{
if($v)
{

	$sql = $conn->query("SELECT * FROM vacTbl WHERE vacID='$v'");
	while($f = $conn->fetchArray($sql))
	{
		$vid = $f['vacID'];
		$vtitle = $f['vacTitle'];
		$postDt = $f['postDate'];
		$text = stripslashes($f['freetext']);
		$typeid = $f['vactypeID'];
		$rid = $f['regionID'];
		$eeid = $f['eeID'];
		$endDt = $f['expDate'];

		$qry1 = $conn->query("SELECT * FROM vactype WHERE vactypeID = '$typeid'");
		while($t = $conn->fetchArray($qry1))
		{
			$type = $t['vactype'];
		}

		$qry2 = $conn->query("SELECT * FROM region WHERE regionID = '$rid'");
		while($u = $conn->fetchArray($qry2))
		{
			$region = $u['regionName'];
		}

		$qry3 = $conn->query("SELECT * FROM ee WHERE eeID = '$eeid'");
		while($w = $conn->fetchArray($qry3))
		{
			$ee = $w['eetype'];
		}

		if($type == "Both")
		{
			$type = "Contract & Permanent";
		}

		$str .= "<h3>Title: <u>$vtitle</u></h3>Expiry date: $endDt<br>Region: $region<br>EE: $ee<br>Vacancy type: $type<br><br>$text";
	}
}
$v = strtok($delim);
}

echo $str;
//$out1 = ob_get_contents();	
unset($_SESSION['vacs']);

//redirect back to the vacancies page
header("Location: vacancies.php");
exit;
ob_end_flush();
?>	
</body>
<?php

?>
</html>

Link to comment
Share on other sites

You cant sent headers after white spaces e.g. any html code will make the header fail.

 

I usually use meta tage refresh to redirect people when im unable to use header.

 

also why are you wanting to show html but direct people immediatly also? It doesnt make sence as they would never see the output in the first place.

 

I use the meta refresh on account created pages to redirect after 10 secs.

 

 

Regards

Liam

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.