Jump to content

$_SESSIONS['PHP_SELF'] not working on server


ppgpilot

Recommended Posts

 

I ran across a problem that I have not been able to solve when submitting a form to be handled by the same page.

 

I am using $_SERVER[‘PHP_SELF’]

 

On local Windows XP  pro  it works fine

 

On my server -  Linix / vieving with IE-7 / Fire Fox it does not work

 

I have been using $_SERVER[‘PHP_SELF’] to handle files for well over a year with 100% success.

 

The problem is this:

usually the $_SERVER[‘PHP_SELF’] provides the file address: i.e.

 

support_files/comment.php

 

and not the host address "mysite.com. Clicking submit has always prepended the Host – i.e

 

mysite.com/  --- and it all worked well as the display url was ---

 

mysite.com/support_files/comment.php

 

Recently, for some reason I cannot discover, when I click submit, I only get the $_SERVER[‘PHP_SELF’] (file name) and not the host info. and this fails.

 

No problems on XP pro on my local server

 

And this only happens in one set of folders and subfolders on the server and all files and folders are affected in that set – Other folders apart from this one set seem unaffected and the $_SERVER[‘PHP_SELF’] works fine.

 

While trying to track the problem down I find the following

 

removing the $_SERVER[‘PHP_SELF’] in IE7 will cause a default and it will work :

 

mysite.com/ support_files/comment.php

 

placing any character in front of $_SERVER[‘PHP_SELF’] will once again prepend the host, but also other address information and fails i.e.  placing a “-” in front        -$_SERVER[‘PHP_SELF’] makes the following

 

http://mysite.com/support_files-//support_files/comment.php

 

so I am replacing the $_SERVER… with the absoulte URL and everything works.

 

What might be wrong in this situation? I prefer to use the $_SERVER Global

 

I did introduce a .htaccess file about the same time to turn off the auto.session_start – but changing the settings or removing .htaccess completly does not seem to have an  affect.

 

Perhps you have come upon this before.

 

Puzzled!

 

David

 

Link to comment
Share on other sites

i always use linux servers... this works perfectly :-)

 

<?
function get_url(){
if(!empty($_SERVER['QUERY_STRING'])) return 'http://'.$_SERVER['SERVER_NAME'].$_SERVER['PHP_SELF'].'?'.$_SERVER['QUERY_STRING'];
else return 'http://'.$_SERVER['SERVER_NAME'].$_SERVER['PHP_SELF'];
}
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.