GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   PHP help please (https://gfy.com/showthread.php?t=83428)

3Xguru 10-18-2002 01:17 PM

PHP help please
 
I want to make a script with a plug and play adult flash e-card that webmasters can put on their website. I have searched the web resources but I cannot seem to understand how to make the script load in a variable the adress of the script(the complete addres).


So if the script is located at http://www.domain.com/script.php I want to load this URL into a variable dynamicaly, and if the script name is changed, so does the variable.

Can anione help?

notjoe 10-18-2002 01:21 PM

Quote:

Originally posted by 3Xguru
I want to make a script with a plug and play adult flash e-card that webmasters can put on their website. I have searched the web resources but I cannot seem to understand how to make the script load in a variable the adress of the script(the complete addres).


So if the script is located at http://www.domain.com/script.php I want to load this URL into a variable dynamicaly, and if the script name is changed, so does the variable.

Can anione help?


Create a file, phpinfo.php for example, and put <?phpinfo();?>
. you will find the variable (and many more) in the output.

Joe

Rory 10-18-2002 01:24 PM

$_SERVER['PHP_SELF'] will give you the path of the php file that is executing...... so do this :

$current_page = $_SERVER['PHP_SELF'];
$full_web = "http://www.yourdomain.com" . $current_page;

Rory 10-18-2002 01:28 PM

That will work for PHP 4.1+ .. for lower version numbers (get your ass current lol) try $HTTP_SERVER_VARS instead of $_SERVER . That should work even if php is buried in several different dirs. So DONT change the "http://www.yourdomain.com" part to something like "http://www.yourdomain.com/path/to" . Just thought I would clarify.

Rory
:helpme

3Xguru 10-18-2002 01:39 PM

Quote:

Originally posted by Rory
$_SERVER['PHP_SELF'] will give you the path of the php file that is executing...... so do this :

$current_page = $_SERVER['PHP_SELF'];
$full_web = "http://www.yourdomain.com" . $current_page;

Yes, I understand the PHP_SELF part, but I also need the name of the domain to be loaded dynamicaly. How do I do that?

Rory 10-18-2002 01:42 PM

$_SERVER['HTTP_HOST'] then

Rory 10-18-2002 01:53 PM

So here is everything you need :
PHP Code:

$current_host $_SERVER['HTTP_HOST'];
$current_path $_SERVER['PHP_SELF'];

$full_web_path "http://" $current_host $current_path

Now the variable $full_web_path contains the correct info. The "http://" is optional. Like I said above if your PHP < 4.1 you will need to use $HTTP_SERVER_VARS instead of $_SERVER. So this would replace if you are running an earlier version of PHP :
PHP Code:

$current_host $HTTP_SERVER_VARS['HTTP_HOST'];
$current_path $HTTP_SERVER_VARS['PHP_SELF'];

$full_web_path "http://" $current_host $current_path

Hope that helps.

Rory
:helpme

3Xguru 10-18-2002 02:08 PM

I have seen some of the variables that PHP has using the phpself() function and I now know how to solve the problem.
hanks to all, especialy to NotJoe

Rory 10-18-2002 02:09 PM

http://www.php.net/manual/en/reserved.variables.php

3Xguru 10-18-2002 02:17 PM

Quote:

Originally posted by Rory
So here is everything you need :
PHP Code:

$current_host $_SERVER['HTTP_HOST'];
$current_path $_SERVER['PHP_SELF'];

$full_web_path "http://" $current_host $current_path

Now the variable $full_web_path contains the correct info. The "http://" is optional. Like I said above if your PHP < 4.1 you will need to use $HTTP_SERVER_VARS instead of $_SERVER. So this would replace if you are running an earlier version of PHP :
PHP Code:

$current_host $HTTP_SERVER_VARS['HTTP_HOST'];
$current_path $HTTP_SERVER_VARS['PHP_SELF'];

$full_web_path "http://" $current_host $current_path

Hope that helps.

Rory
:helpme

Thanks again. We need more helping people like you on this board.


All times are GMT -7. The time now is 02:06 AM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123