r-it Posted March 7, 2008 Share Posted March 7, 2008 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 https://forums.phpfreaks.com/topic/94865-headers-already-sent/ Share on other sites More sharing options...
shocker-z Posted March 7, 2008 Share Posted March 7, 2008 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 https://forums.phpfreaks.com/topic/94865-headers-already-sent/#findComment-485938 Share on other sites More sharing options...
r-it Posted March 7, 2008 Author Share Posted March 7, 2008 Thanks a lot Liam, i totally forgot about that. Link to comment https://forums.phpfreaks.com/topic/94865-headers-already-sent/#findComment-485940 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.