ppgpilot Posted April 20, 2007 Share Posted April 20, 2007 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 Quote Link to comment Share on other sites More sharing options...
taith Posted April 20, 2007 Share Posted April 20, 2007 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']; } ?> Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted April 20, 2007 Share Posted April 20, 2007 The string "$_SERVER[‘PHP_SELF’] " has "smart quotes" in it, replace then (‘ ’) with regular single quotes. Ken Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.