Hi there, I needed a code that gets the current URL and stores it in a variable. Then I need a code which can fix that variable after another URL. For example if the current URL is digitalpoint.com/test.htm, the code will store it into a variable and then it will fix it after something like "seo.com/pagedetails.php?=" therefore resulting in "seo.com/pagedetails.php?=digitalpoint.com/test.htm" and then it should run that page as well. So can anyone make this script for me? IT
The test.htm bit is stored as $PHP_SELF and I assume you know the sitename? $var="sitename.com/$PHP_SELF"; $newpage="seo.com/pagedetails.php?=$var";
The variable $_SERVER['PHP_SELF'] would be better (use of $PHP_SELF is deprecated), or you could use $_SERVER['REQUEST_URI']. You can also use $_SERVER['HTTP_HOST'] to get the name of your site. $_SERVER['SCRIPT_URI'] can also work, and I think is the same. Cryo.
Whenever you want a quick reference of what variables are available to you on your specific host, you can use: print_r($_SERVER); Some variables found on Linux servers are not found on IIS servers. See www.php.net for more information on Global Variables. If you're just coding for your own server then it's not really an issue. Just run the code I posted above and what you see is what you can use. If you're coding for software/code to be sold or distributed, then you need to know the differences between global variables available on different types of hosts and the ways of getting around the limitations.