I’m experiencing a very strange problem with my php scriptie. I’ve been working on this little scriptie and all was fine until three weeks ago. Now it generates a header warning on the remote server, but strangely not on my test server.
- I wrote up another little scriptie (see below) to test the header and make sure it was not the server. Same result: remote generates a warning and local does not.
- I tested just the header in a php redirect file and this works correctly on remote host.
I’ve posted elsewhere (I know, I should have brought it here first and went through the full broadsides of comments warning me to eliminate any, all, every, not a one, preceding space before the header function. This did not fix the problem, and if the script works without error on my localhost then, QED, its not in my file, per se…cuz bad code with spaces is bad code wherever you put it. haha
This leaves me with few ideas of how to go forward. One thought is try to cause my localhost to repeat the problem. I was adding a magic_quotes scriptie when I got the flat tire, so I turned it on in my localhost setup to no effect.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<?php
var_dump($submitted = isset($_POST['submitted']) ?
$_POST['submitted'] :
NULL);
if ($submitted) {
header ('Location: menu_edit.php?added=1');
print 'This is wrong!';
} else {
print 'Waiting...';
}
?>
<form method="post" action="<?php $_SERVER['PHP_SELF'] ?>">
<input type="submit" value="Submit" name="submitted" />
</body>
</html>
Now, just moving the php to the top is not enough. I was working with a fellow in the other thread. We tried this next version. (NOTE: As I’m posting this I also rechecked the code to be sure I had the right version. Originally we believed he found a solution; however, as I recheck the file it is not working on the remote host and is working on localhost. Also, I decided to leave the other thread, cuz I don’t agree with the the fellow’s conclusion ignoring the fact my script, above, works on my localhost. Its not personal. I just need to resolve this problem
<?php
var_dump($submitted = isset($_POST['submitted']) ? $_POST['submitted'] : NULL);
if ($submitted) {
header('Location:menu_edit.php?added=1');
} else {
print 'Waiting for you.......';
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<form method="post" action="<?php $_SERVER['PHP_SELF'] ?>">
<input type="submit" value="Submit" name="submitted" />
</form>
</body>
</html>
And if that wasn’t enough…I set this up on two remote hosting services. Both recreated the error. Maybe the answer is about these bare bones shared hosting setups? I loaded my server using YUM install. I also have not updated it since install in November. Maybe there was an update to some server plugin during these last four or five weeks?
If I can’t get an answer to this problem, I’m going to contact php.net and demand a refund!