Wrox Programmer Forums
|
Beginning PHP Beginning-level PHP discussions. More advanced coders should post to the Pro PHP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning PHP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 9th, 2003, 05:53 AM
Authorized User
 
Join Date: Jun 2003
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Default header redirect

On a couple of the pages on my website I use this to redirect

header("Location: http://".$_SERVER['HTTP_HOST'] .dirname($_SERVER['PHP_SELF']) ."/results.php");

and it works fine one my test server and the actuall server it is on. But I gave my friend a copy to test on their test server and the redirect part is causing them problems. It seems to be missing out which directory the files are in, but it does get the host.

so i tried putting this on the page but it displays nothing

echo dirname($_SERVER['PHP_SELF']);

But it should show the folder it is in.

I have been searching but cannot find anything about why it isnt working.

Anyone else had this problem?
Any ideas?
 
Old September 9th, 2003, 08:14 AM
Authorized User
 
Join Date: Jun 2003
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Just done a test, I was running php 4.3.0 and my friend was running 4.3.3. So I uninstalled the php on my test server and installed php 4.3.3 because this was the only difference between our setup. And not I get the same problem that they were getting. So it looks like it could be something to do with 4.3.3version.

Is it done in a different way now?

No longer dirname($_SERVER['PHP_SELF'])?

Or is it to do with php and should I get them to install version 4.3.0 since it seems to work ok?
 
Old September 9th, 2003, 11:31 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 836
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I'd submit a bug report to PHP if you think there's a bug in 4.3.3. Give them a simple sample snippet (the one you posted seems adequate) and tell them the output you're getting for both versions. I can't imagine that it'd suddenly STOP working in 4.3.3, especially since that function's been around since PHP3.



Take care,

Nik
http://www.bigaction.org/
 
Old September 9th, 2003, 11:49 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 836
Thanks: 0
Thanked 0 Times in 0 Posts
Default

For what it's worth, I just installed 4.3.3 on my Win2K machine and the script works fine. I'm not using header(), I'm using echo():

<?php
echo "<pre>\n";
echo "\$_SERVER['PHP_SELF'] is: {$_SERVER['PHP_SELF']}\n";
echo "dirname(\$_SERVER['PHP_SELF']) is: ";
echo dirname($_SERVER['PHP_SELF']);
echo "\n";
echo "</pre>\n";
?>

My output on PHP versions 4.3.1, 4.3.2, and 4.3.3 are all the same:

$_SERVER['PHP_SELF'] is: /~phptest/dirname.php
dirname($_SERVER['PHP_SELF']) is: /~phptest



Take care,

Nik
http://www.bigaction.org/
 
Old September 9th, 2003, 01:16 PM
richard.york's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts
Default

I've had the same problem. Usually only on my develop. machine. Which runs Xitami/PHP 4.3.3

I wrote this fix:

if (!isset($_SERVER["PHP_SELF"]) || empty($_SERVER["PHP_SELF"])) {

$_SERVER["PHP_SELF"] = $_SERVER["SCRIPT_NAME"];

}

My use of PHP_SELF usually does not rely on sub-folders or anything more than the script name.. and I am sure there are other environment variables that would fit the bill.

I would have to agree with Nik.. it is likely a bug.

: )
Rich

:::::::::::::::::::::::::::::::::
Smiling Souls
http://www.smilingsouls.net
:::::::::::::::::::::::::::::::::
 
Old September 9th, 2003, 01:25 PM
Authorized User
 
Join Date: Jun 2003
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for the advice guys I have now submitted it.

I think it is specific to xitami because I have just finished testing it on IIS and that worked fine.

Thanks again





Similar Threads
Thread Thread Starter Forum Replies Last Post
Redirect SKhna ASP.NET 2.0 Basics 1 February 9th, 2008 08:14 AM
redirect:write printing xml header in output csv jon.london XSLT 4 October 1st, 2007 05:47 AM
header redirect not working guillermo Beginning PHP 2 June 23rd, 2006 05:33 AM
Q. How do I redirect users? (Location Header) richard.york PHP FAQs 0 April 3rd, 2004 07:40 PM
Header functions is same to asp respose.redirect() knight Beginning PHP 3 March 12th, 2004 04:06 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.