#27587 [Bgs]: header() works, but not with variables, after a POST request

From: Date: Sat, 13 Mar 2004 18:14:38 +0000
Subject: #27587 [Bgs]: header() works, but not with variables, after a POST request
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-56398@lists.php.net to get a copy of this message
 ID:               27587
 User updated by:  webmaster at digitalanime dot nl
 Reported By:      webmaster at digitalanime dot nl
 Status:           Bogus
 Bug Type:         Output Control
 Operating System: Linux
 PHP Version:      4.3.4
 New Comment:

Ehm.. Sorry for double-blasting your database, but I wanted to say that
the variables aren't empty.

All values come through clearly and everything works.

If I do this:

<?php
ob_start();
// my stuff (only that form thingie, which is above here..
echo $_SERVER['REQUEST_URI'];
header('Location: http://www.digitalanime.nl' .
$_SERVER['REQUEST_URI']);
// my stuff..
ob_end_flush();
?>

I get this on my screen:
/index.php?p=beep

And about:blank in the title bar..


Previous Comments:
------------------------------------------------------------------------

[2004-03-13 13:11:57] webmaster at digitalanime dot nl

So... It isn't really a bug?

Well, then I'll going to waste my time on finding more solutions for my
'problem'. :)

Well, I would like to thank you for the support you offered and the
time you've taken to try to help me. :)

------------------------------------------------------------------------

[2004-03-13 13:08:11] derick@php.net

Perhaps the variables are just empty? Anyway, this works fine using
those variables unless they are not set, please use the
php-general@lists.php.net mailinglist for support questions.

------------------------------------------------------------------------

[2004-03-13 13:01:23] webmaster at digitalanime dot nl

Yes, I already tried that several times... But without result.

header('Location: index.php');
Works.

header('Location: ' . $_SERVER['PHP_SELF']);
Doesn't work.

And so with this one:

header('Location: http://www.digitalanime.nl/index.php?p=beep
Works.

header('Location: http://www.digitalanime.nl' .
$_SERVER['REQUEST_URI']);
Doesn't work.
header('Location: http://www.digitalanime.nl/' .
$_SERVER['REQUEST_URI']);
Doesn't work.

In all examples with Doesn't work, I get the same result, a blank page.

------------------------------------------------------------------------

[2004-03-13 12:50:05] derick@php.net

Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system
is not the
appropriate forum for asking support questions. 

Thank you for your interest in PHP.

You're abusing the header function, "Location" must be a capital "L"
and you are required to specify the FULL URI:
http://server.example.com/filename.php

------------------------------------------------------------------------

[2004-03-13 12:46:21] webmaster at digitalanime dot nl

Description:
------------
Hello there..

I've been fighting with this code for about a day or two, but it just
doesn't seem to work..

If I use output buffering, post a form and want to do a header(), it
works.... Only it doesn't when I want to use $_SERVER['REQUEST_URI']..

Reproduce code:
---------------
<?php
ob_start(); // start the outputbuffer
if(!empty($_POST) && !isset($_SESSION['form'])) { // my POST is full,
but we can't find a session variable... Strange.. There's someone
fucking with my site
 header('location: ' . $_SERVER['REQUEST_URI']);
}
if(empty($_POST)) { // POST is empty... Let's show a form here:
 // do my form here + make a session for the form
}
else { // POST is NOT empty... Let's handle the data
 // handle my data here
}
if(!empty($_POST) && isset($_SESSION['form'])) { // my POST is full,
and the session exists.. Fine, let's unset() it. :)
 unset($_SESSION['form']); // unsetting the session..
}
ob_end_flush();
?>

Expected result:
----------------
Well, the first thing I wanted to see, is that the form shows up (yes,
it really does, so that's not wrong..)

After that, I'll fill it in and submit it..

I get my data and so.. But, if I refresh, the browser asks me if I want
to send the data again.... I click yes, and my code works, except for
the header().

If I put header('location: index.php'); in it, It works, but not with
$_SERVER['REQUEST_URI'].

EVERYTHING works, except for REQUEST_URI, QUERY_STRING and any of the
GET variables..

Actual result:
--------------
A whole blank page..

With about:blank in the title bar..

Al that, nothing more, nothing less.


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=27587&edit=1


Thread (6 messages)

« previous php.bugs (#56398) next »