|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2004-03-13 12:46 UTC] 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.
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 30 06:00:02 2025 UTC |
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.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..