Jump to content

Archived

This topic is now archived and is closed to further replies.

larswise

header("Location ... Problem in PHP 5

Recommended Posts

Hello,

I just upgraded my PHP to v5 and one of my scripts doesn't seem to work anymore (the script taking care of my orders). The script was written about two years ago and worked fine with php 4.2.3, It's an ugly script but it does (did) the job.

The problem is when i output my head.inc file (with html) before a header("Location: $var"); it simply stops and just displays an empty page with header.inc and footer.inc.

The code looked like this:

include 'head.inc';
if(strcmp($_GET['action'], "subm") == 0) {
if($_GET['step'] == "start" || $_GET['ccat'] == "select") {

when i reach the redirect code, the $_GET['action'] is still set to "subm"

I tried:

if(strcmp($_GET['action'], "subm") == 0) {
if($_GET['step'] == "start" || $_GET['ccat'] == "select") {
include 'head.inc';

But then, as the script is made, the page displays without any html header when neither step == start or ccat == select :)

Is there any good workaround to force a redirect even if HTML is outputted ?

Thanks in advance

Lars



Share this post


Link to post
Share on other sites
Use output buffering in that case

Add [code=php:0]ob_start();[/code] after the opening php tag (<?php) and [code=php:0]ob_end_flush();[/code] before the closing php tag (?>)

Share this post


Link to post
Share on other sites

×

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.