header not working

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
gotornot
Forum Commoner
Posts: 54
Joined: Fri Jul 31, 2009 2:30 am

header not working

Post by gotornot »

Hi

I am trying to use a header redirect AFTER html output which is obviously not going to work.
I want to run a script in the background get a return code ie a 1 or 0 from the page that data is submitted to then after send the user on to the next step

i cant seem to get it to work any ideas

// now we must send the data that is collected to the url
ob_start();
ignore_user_abort(true);
set_time_limit(5); // MAXIMUM RUNNING TIME CAN BE SET TO WHATEVER IN SECONDS I BELIVE
//THE HTML BELOW CAN BE CHANGED.
echo '<img src="waitani.gif" width="250" height="250">';

echo str_repeat("<!-- Flush that stuff --->\n", 256);

header('Connection: close');
header("Content-length: ".ob_get_length());

ob_end_flush(); // fly my pretties!
flush(); // browser should now stop rolling
//ANDY WHATEVER YOU WANT TO HERE.
#header('Location:'.$final_url);
$handle = fopen("$final_url", "r");
$contents2 = fread($handle, 1);
if ($contents2=="1")
{
$test = "1 seen and read";
}else{
$test = "Nothing seen im broke";
}
//now send to a url + $test
exit();
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: header not working

Post by requinix »

If you want to redirect after sending output then you need either a <meta> redirect or JavaScript. You decide. Just keep in mind that browsers don't necessarily respect either.
Post Reply