English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

Hi,

I'm using PHP and I have a form that I want to use on many different sites. Say the form posts to "http://www.whateversite.com/upload.php". Is there a way to detect a site's url and return it as a variable, so I can simply type something like

"$url"."/upload.php"

instead of rewriting the code every time I use the form on a new site?

2006-07-12 06:22:11 · 2 answers · asked by jat212406 1 in Computers & Internet Programming & Design

Ok - I think I got it... This works for what I need:

PHP:
"http://www".$_SERVER[SERVER_NAME]."/upload.php"

or Javascript:

"http://www."+document.domain+"/upload.php"

First time on Yahoo answers. Seems like there should be a way to answer your own question or respond to other's answers

2006-07-12 08:35:47 · update #1

2 answers

you can do this one of two ways:

If the forms are at the path root of the 'upload.php' then you just need to use $_SERVER['REQUEST_URI'] and truncate off the form file name.

The other way is to set a global variable in an include to the upload form. I generally see people keep a whole bunch of random variables that I use regularly (like this) in either a globals.php type file. (better stored outside of httpd's doc root, so noone can request it directly)

2006-07-12 07:02:18 · answer #1 · answered by John J 6 · 0 0

u can also just say "upload.php"
cus if it is in the same directory and the file ur trying to access, then u can just sya thy name, and it will look in the current directory.

if u want to look in a deeper directyory, u can say "/testdir/upload.php"

2006-07-12 14:05:14 · answer #2 · answered by Kristofer 4 · 0 0

fedest.com, questions and answers